tsc似乎没有捡到"排除" tsconfig.json的选项

时间:2016-05-13 12:36:45

标签: typescript angular tsc

我正在努力让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中的其他定义...避免类型定义冲突的解释更多here

所以,当我运行npm run tsc时,我希望tsc忽略main.d.ts以及main中的所有内容,但它没有。

我在tsc ignores tsconfig.json when specific files are defined看到了其他问题,但我在这里没有这个问题。

为什么我的tsconfig.json被忽略了?为什么tsc如此吝啬?!

任何想法都将不胜感激!

哦顺便说一句,错误只是这样的几行错误 - 主文件夹和浏览器文件夹都出错:

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并参考src/typings.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.

1 个答案:

答案 0 :(得分:2)

问题是您在某处引用了排除的main.d.ts。这将从tsc加载,所以你有你的dublicates。