tsc seemingly not picking up “exclude” options fro tsconfig.json

纵饮孤独 提交于 2019-12-23 13:07:10

问题


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.

I have:

package.json
tsconfig.json
typings.json
typings /
    main/ ...etc
    browser/ ...etc
    main.d.ts
    browser.d.ts
src / ...   <source files in here.>

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"
  }
}

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"
  ]
}

and in my package.json / tests object I have:

 "tsc": "tsc",

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

So, when I run npm run tsc, I would expect tsc to ignore main.d.ts and everything in main, but it doesn't.

I have seen other issues where tsc ignores tsconfig.json when specific files are defined, but I don't have that case here.

Why is my tsconfig.json being ignored? Why is tsc being so mean to it?!

Any ideas would be appreciated!

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'.

Edit:

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.

回答1:


The problem was that you referenced the excluded main.d.ts somewhere. This will be loaded from tsc and so you have your dublicates.



来源:https://stackoverflow.com/questions/37210246/tsc-seemingly-not-picking-up-exclude-options-fro-tsconfig-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!