【问题标题】:Subsequent variable declarations must have the same type. Variable 'use' must be of type 'SVGProps', but here has type 'SVGProps'后续的变量声明必须具有相同的类型。变量“use”必须是“SVGProps”类型,但这里有“SVGProps”类型
【发布时间】:2017-10-23 16:27:32
【问题描述】:

我正在使用 typescript 进行编码并使用 awesome-typescript-loader。当我尝试编译我的代码时,我多次收到以下错误:

“[at-loader] 中的错误 ./node_modules/searchkit/node_modules/@types/react/index.d.ts:2790:13 TS2403:后续变量声明必须具有相同的类型。变量 'switch' 必须是 'SVGProps' 类型,但这里有 'SVGProps' 类型。”

我所有的错误都与这个 SVGProps 类型有关。它与它想要的类型相同,所以我应该如何解决这个问题?

在 index.d.ts 中,这些是变量: Variable in index.d.ts

有什么想法吗?

【问题讨论】:

  • 我在使用 @types/react 中的东西和使用 searchkit 时遇到了同样的问题。
  • @mmmveggies 我确实修好了,我会在下面发布答案

标签: javascript reactjs typescript npm react-dom


【解决方案1】:

所以问题是@types/react 安装了两次。就我而言,它安装在 node_modules/@types/react 和 node_modules/searchkit/node_modules/@types/react 下。您需要做的是进入 node_modules/@types/react/index.d.ts 并删除与 SVGProps 有关的所有内容。这将解决它。

【讨论】:

  • 这有什么帮助?我的意思是,它背后的逻辑是什么?
猜你喜欢
  • 2016-04-11
  • 2020-09-11
  • 2017-11-15
  • 2018-04-18
  • 1970-01-01
  • 2017-07-14
  • 2016-11-07
  • 2019-09-04
  • 2017-08-17
相关资源
最近更新 更多