I'm having difficulty with tsc recognizing my tsconfig.json file and compiling my .ts files. I keep encountering duplication errors that I'm trying to prevent using my tsconfig.json.
Here's what I have:
package.json
tsconfig.json
typings.json
typings /
main/ ...etc
browser/ ...etc
main.d.ts
browser.d.ts
src / ... <source files in here.>
This is how my typings.json appears:
{
"ambientDependencies": {
"es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654",
"jasmine": "registry:dt/jasmine#2.2.0+20160412134438",
"node": "registry:dt/node#4.0.0+20160509154515"
}
}
My tsconfig.json is structured as follows:
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"bower_components",
"typings/main",
"typings/main.d.ts"
]
}
In my package.json, under the tests object, I have:
"tsc": "tsc",
I expect my tsconfig.json to instruct tsc to ignore main.d.ts and other definitions in 'main'. More information on avoiding type definition collisions can be found here.
So when I execute npm run tsc
, I anticipate tsc to overlook main.d.ts and everything in 'main', yet it doesn't.
I've come across instances where tsc disregards tsconfig.json when specific files are defined, but that's not the case here.
Why is tsc overlooking my tsconfig.json? Why isn't tsc cooperating?
Your thoughts would be greatly appreciated!
By the way, the errors consist of multiple lines like these - affecting both main and browser folders:
typings/main/ambient/node/index.d.ts(2067,18): error TS2300: Duplicate identifier 'PassThrough'.
typings/main/ambient/node/index.d.ts(2072,9): error TS2300: Duplicate identifier 'showHidden'.
typings/main/ambient/node/index.d.ts(2073,9): error TS2300: Duplicate identifier 'depth'.
typings/main/ambient/node/index.d.ts(2146,9): error TS2300: Duplicate identifier 'isTTY'.
...
Edit:
After modifying my tsconfig.json to exclude browser and browser.d.ts, and referencing typings/main.d.ts in my reference path in src/typings.d.ts
, I now encounter these errors:
src/typings.d.ts(3,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'module' should be of type 'NodeModule', but has '{ id: string; }' type.
typings/main.d.ts(1,1): error TS6053: File 'typings/main/ambient/angular-protractor/index.d.ts' not found.
typings/main.d.ts(5,1): error TS6053: File 'typings/main/ambient/selenium-webdriver/index.d.ts' not found.