tsc 似乎没有为 tsconfig.json 选择 "exclude" 选项

tsc seemingly not picking up "exclude" options fro tsconfig.json

我正在努力让 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 / 测试对象中我有:

 "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 中切换到 exlcude 浏览器和 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.

问题是您在某处引用了排除的 main.d.ts。这将从 tsc 加载,因此您有重复项。