我正在努力让tsc识别我的tsconfig.json文件并编译我的.ts文件。它遇到了重复错误,我正在尝试通过我的tsconfig.json来避免这些错误。
我已经做了以下几点:
package.json
tsconfig.json
typings.json
typings /
main/ ...etc
browser/ ...etc
main.d.ts
browser.d.ts
src / ... <source files in here.>
我的typings.json文件如下:
{
"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"
}
}
我的tsconfig.json文件如下所示:
{
"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"
]
}
在我的“package.json / tests”对象中,我有以下内容:
"tsc": "tsc",
因此,我期望我的tsconfig.json告诉tsc忽略main.d.ts和main中的其他定义...更多关于避免类型定义冲突的解释可以在这里找到。
所以,当我运行
npm run tsc
时,我期望tsc忽略main.d.ts和main中的所有内容,但它没有。我看到其他问题,在那些问题中,当定义了特定文件时,tsc会忽略tsconfig.json,但在这里我没有这种情况。
为什么我的tsconfig.json被忽略了?为什么tsc对它如此不友好?
如果有任何想法,将不胜感激!
哦,顺便说一下,错误只是几行像这样的错误 - 错误发生在main和browser文件夹中:
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(2074,9): error TS2300: Duplicate identifier 'colors'.
typings/main/ambient/node/index.d.ts(2075,9): error TS2300: Duplicate identifier 'customInspect'.
typings/main/ambient/node/index.d.ts(2136,5): error TS2300: Duplicate identifier 'export='.
typings/main/ambient/node/index.d.ts(2144,9): error TS2300: Duplicate identifier 'isRaw'.
typings/main/ambient/node/index.d.ts(2146,9): error TS2300: Duplicate identifier 'isTTY'.
typings/main/ambient/node/index.d.ts(2149,9): error TS2300: Duplicate identifier 'columns'.
typings/main/ambient/node/index.d.ts(2150,9): error TS2300: Duplicate identifier 'rows'.
typings/main/ambient/node/index.d.ts(2151,9): error TS2300: Duplicate identifier 'isTTY'.
typings/main/ambient/node/index.d.ts(2158,18): error TS2300: Duplicate identifier 'Domain'.
编辑:
在我的tsconfig.json中交换,将浏览器和browser.d.ts排除在外,并在我的参考路径中引用typings/main.d.ts在中,我只会得到以下这些错误:
src/typings.d.ts(3,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'module' must be of type 'NodeModule', but here has type '{ id: string; }'.
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.