Upgraded to Typescript 2.0 (2.1.6) and it started giving "Duplicate identifier" errors. After taking a closer look it turned out that Typescript started importing @types from all upper directories (essentially other projects).
What should be the configuration to let Typescript to ignore upper node_modules?
src
└── node_modules << *** how to ignore it? ***
└── @types
└── my.app << *** how to build this folder and down only? ***
└── node_modules
└── @types
EDIT: Here is an example of error I'm getting:
typings/globals/mocha/index.d.ts(30,13): error TS2300: Duplicate identifier 'describe'. ../../../node_modules/@types/jasmine/index.d.ts(9,18): error TS2300: Duplicate identifier 'describe'.
listFiles: true shows @types/jasmine being imported from upper folder:
C:/src/<project>/<folder>/<my.app>/typings/globals/mocha/index.d.ts
C:/src/node_modules/@types/jasmine/index.d.ts
If I rename upper node_modules folder then build succeeds.
The official documentation specifies that node_modules in current directory and all parents will be traversed unless you specify typeRoots
.
So in theory, the answer should be this:
{
"compilerOptions": {
"typeRoots": [
"./node_modules/@types"
]
}
}
Since you still want to include the types from the current directory.
Unfortunately this doesn't seem to work correctly for me.
In this helps anyone, setting "types": []
in my tsconfig.json worked for me. See this github comment.
https://github.com/Microsoft/TypeScript/issues/13992#issuecomment-279020210
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