I have a nodeJS project based on this seed project. It has two tsconfig.json files which look like this:
{
"compilerOptions": {
"target": "es6",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"../node_modules"
]
}
however, despite the exclude node_modules, I get loads of errors, some of which I've shown below. This has occured since I started using the new npm i @types/xyz approach.
[0] node_modules/@types/core-js/index.d.ts(21,14): error TS2300: Duplicate identifier 'PropertyKey'.
[0] node_modules/@types/core-js/index.d.ts(85,5): error TS2687: All declarations of 'name' must have identical modifiers.
[0] node_modules/@types/core-js/index.d.ts(145,5): error TS2403: Subsequent variable declarations must have the same type. Variable '[Symbol.unscopables]' must be of type '{ copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: ...', but here has type 'any'.
[0] node_modules/@types/core-js/index.d.ts(262,5): error TS2687: All declarations of 'flags' must have identical modifiers.
[0] node_modules/@types/core-js/index.d.ts(276,5): error TS2687: All declarations of 'EPSILON' must have identical modifiers.
[0] node_modules/@types/core-js/index.d.ts(311,5): error TS2687: All declarations of 'MAX_SAFE_INTEGER' must have identical modifiers.
I just ran into this issue after upgrading to ts2.0 with an anguler2 project.
I'm using typings for now and have a lot of dependencies. At least on of them is including @types, which duplicates some of the imports. But they are required, I can't just delete the folder / dependency (like other have suggested).
On here I found a pointer to the solution which helped me: https://github.com/Microsoft/TypeScript/issues/11257
Sample from lucassp:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"types": []
},
"exclude": [
"../node_modules"
]
}
I simply had to add "types": [] to the tsconfig.json file, which makes it include none of the types in @types (since all of them are managed by typings currently).
Here's the description of the compiler option from the doc:
--types string[]
List of names of type definitions to include. See @types, –typeRoots and –types for more details.
Microsoft seems to think that @types is the new black typescript definition imports. Read more info on this here.
Eventually I might migrate, but I'll let the dust settle, first.
I was getting the same errors. I am not using the explicit @types/* declarations. However, it looks like updating packages have added those as dependencies.
I got those errors to disappear by removing entries from typings.json. Basically, any declaration that is is under node_modules/@types/ should not be duplicated in typings.json.
Don't forget to run typings prune after updating your typings.json file so extra typings are deleted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With