问题描述
我正在尝试在一个项目上运行 Webpack,但出现多个错误
I am trying to run Webpack on a project and I am getting multiple errors
node_modules/@types/core-js/index.d.ts
error TS2304: Cannot find name 'PropertyKey'.
...
node_modules/@types/core-js/index.d.ts
error TS2339: Property 'for' does not exist on type 'SymbolConstructor'.
我应该安装所有类型,所以我不确定这些是从哪里来的.我尝试从编译的项目中复制 package.json ,但没有帮助.我错过了什么?
I should have all my typings installed so I am not sure where these are coming from. I tried copying over a package.json from a project that compiles but it didn't help. What am I missing?
我的 tsconfig 看起来像这样
My tsconfig looks like this
{
"compilerOptions": {
"target": "es5",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}
推荐答案
我在 0.9.35 使用 @types/core-js 时遇到同样类型的错误
I am getting the same kind of errors with @types/core-js at 0.9.35
可能是别的东西..
编辑
上周回购发生了一些变化.您可以在 github 上阅读问题并通过以下链接查看更改:
There has been some changes on the repo last week. You can read the issue on github and see the changes via these links:
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15104
我的解决方案是改变
"lib": ["es5", "dom"]
到 "lib": ["es6", "dom"]
在 compilerOptions
对象在我的 tsconfig 文件中.
"lib": ["es5", "dom"]
to "lib": ["es6", "dom"]
in the compilerOptions
object in my tsconfig files.
通过这样做,我使错误消失了,而无需降级到 0.9.35
By doing this I made the errors disappear without downgrading to 0.9.35
注意:你不需要改变目标(我的还是es5)
Note: You dont need to change the target (mine is still es5)
这篇关于找不到名称“PropertyKey"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!