tsc似乎没有选择“排除" tsconfig.json的选项 [英] tsc seemingly not picking up "exclude" options fro tsconfig.json
问题描述
我正在努力让tsc提取我的tsconfig.json文件并编译我的.ts文件.它会遇到重复错误,我想通过tsconfig.json来避免.
I am struggling to get tsc to pick up my tsconfig.json file and compile my .ts files. it runs into duplication errors which I am trying to avoid with my tsconfig.json.
我有:
package.json
tsconfig.json
typings.json
typings /
main/ ...etc
browser/ ...etc
main.d.ts
browser.d.ts
src / ... <source files in here.>
我的types.json如下:
My typings.json looks like:
{
"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看起来像这样:
My tsconfig.json looks like this:
{
"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对象中,我有:
and in my package.json / tests object I have:
"tsc": "tsc",
所以我希望我的tsconfig.json告诉tsc忽略main.d.ts和main中的其他定义...避免类型定义冲突的详细说明
So I would expect my tsconfig.json to tell tsc to ignore the main.d.ts and the other definitions in main... Avoiding type definition collisions is explained a little more here
因此,当我运行npm run tsc
时,我希望tsc忽略main.d.ts和main中的所有内容,但是不会.
So, when I run npm run tsc
, I would expect tsc to ignore main.d.ts and everything in main, but it doesn't.
我还看到了其他问题,其中 tsc在定义特定文件时会忽略tsconfig.json ,但我这里没有这种情况.
I have seen other issues where tsc ignores tsconfig.json when specific files are defined, but I don't have that case here.
为什么我的tsconfig.json被忽略?为什么tsc如此卑鄙?!
Why is my tsconfig.json being ignored? Why is tsc being so mean to it?!
任何想法将不胜感激!
顺便说一句,错误只是几行这样的错误-主文件夹和浏览器文件夹均发生错误:
Oh by the way, the errors are just several lines of errors like this - errors occur for 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(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中的exlcude浏览器和browser.d.ts并在src/typings.d.ts
的参考浴中引用了types/main.d.ts之后,我仅遇到以下错误:
After swapping to exlcude browser and browser.d.ts in my tsconfig.json and referring to typings/main.d.ts in my reference bath in src/typings.d.ts
, I just get these errors:
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.
推荐答案
问题是您在某处引用了排除的main.d.ts.这将从tsc加载,因此您有重复项.
The problem was that you referenced the excluded main.d.ts somewhere. This will be loaded from tsc and so you have your dublicates.
这篇关于tsc似乎没有选择“排除" tsconfig.json的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!