后续的变量声明必须具有相同的类型。变量 'use' 的类型必须是 'SVGProps',但这里的类型是 'SVGProps'

Subsequent variable declarations must have the same type. Variable 'use' must be of type 'SVGProps', but here has type 'SVGProps'

我正在用 typescript 编码并使用 awesome-typescript-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安装了两次。在我的例子中,它安装在 node_modules/@types/react 和 node_modules/searchkit/node_modules/@types/react 下。您需要做的是进入 node_modules/@types/react/index.d.ts 并删除与 SVGProps 有关的所有内容。这将修复它。