pitosalas pitosalas - 2 months ago 11
TypeScript Question

Typescript, confusing "duplicate identifier" error message

Can you help me understand why I am getting this and many more errors of this kind? Link to github as well as key code snippets below. I think I have a basic misunderstanding of how the dependency and "include" chaining works. Thanks!

csvproc(master)> tsc
node_modules/typescript/bin/lib.core.d.ts(83,5): error TS2300: Duplicate identifier 'configurable'.
node_modules/typescript/bin/lib.core.d.ts(84,5): error TS2300: Duplicate identifier 'enumerable'.
node_modules/typescript/bin/lib.core.d.ts(85,5): error TS2300: Duplicate identifier 'value'.
node_modules/typescript/bin/lib.core.d.ts(86,5): error TS2300: Duplicate identifier 'writable'.


All code can be found here.

my tsconfig.json:

{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"outDir": "built/",
"sourceMap": true,
"target": "es5"
}
}


My tsd.json:

{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node-0.10.d.ts": {
"commit": "6387999eb899d0ba02d37dd8697647718caca230"
},
"should/should.d.ts": {
"commit": "e1182d56ccb192379eade6055d9ba3fb6a0bacc4"
}
}
}


My tsd.d.ts:

{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node-0.10.d.ts": {
"commit": "6387999eb899d0ba02d37dd8697647718caca230"
},
"should/should.d.ts": {
"commit": "e1182d56ccb192379eade6055d9ba3fb6a0bacc4"
}
}
}

Answer

This is because of the combination of two things:

If no "files" property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories. When a "files" property is specified, only those files are included.

Fix

Either list files explicitly or have something like atom-typescript generate this key for you : https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#filesglob

Comments