Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find name 'PropertyKey'

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'.

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?

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"
  ]
}
like image 491
Jackie Avatar asked Mar 11 '17 17:03

Jackie


2 Answers

I am getting the same kind of errors with @types/core-js at 0.9.35

Could be something else..

EDIT

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

https://github.com/DefinitelyTyped/DefinitelyTyped/pull/15108/commits/f2c5c990e448550fcebec071c25e6a1e5766dde7

My solution was to change

"lib": ["es5", "dom"] to "lib": ["es6", "dom"] in the compilerOptions object in my tsconfig files.

By doing this I made the errors disappear without downgrading to 0.9.35

Note: You dont need to change the target (mine is still es5)

like image 76
Kemal Yalcinkaya Avatar answered Sep 21 '22 12:09

Kemal Yalcinkaya


For me the answer was...

"compilerOptions": {
  ...
  "lib": [
    "es2016",
    "dom"
  ]
},
like image 33
Jackie Avatar answered Sep 21 '22 12:09

Jackie