令人困惑的&Quot;重复标识符&TypeScrip错误消息 [英] Confusing "duplicate identifier" Typescript error message
本文介绍了令人困惑的&Quot;重复标识符&TypeScrip错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么我会收到这样的错误以及更多这样的错误?我正在添加一个链接到repo以及下面的关键代码片段。我想我对依赖关系和"包含"链接的工作原理有一个基本的误解。
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'.
我的tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"outDir": "built/",
"sourceMap": true,
"target": "es5"
}
}
我的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"
}
}
}
我的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"
}
}
}
推荐答案
这是两个因素共同作用的结果:
tsconfig
没有任何files
节。发件人http://www.typescriptlang.org/docs/handbook/tsconfig-json.html如果tsconfig.json中不存在"files"属性,则编译器默认包含包含目录和子目录中的所有文件。当指定"Files"属性时,仅包括这些文件。
将
typescript
包括为NPM依赖项:node_modules/typescript/
这意味着将包括所有typescript
...无论如何,您的项目中都隐式包含lib.d.ts
(http://basarat.gitbook.io/typescript/content/docs/types/lib.d.ts.html),并且它与NPM版本的TypeScrip附带的lib.d.ts
冲突。
修复
列表files
或include
显式https://basarat.gitbook.io/typescript/docs/project/files.html🌹
这篇关于令人困惑的&Quot;重复标识符&TypeScrip错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文