TS2300: Duplicate identifier问题的解决
TS2300: Duplicate identifier问题的解决
Typescript编译时遇到d.ts中的定义冲突:
tsc -p ./
../../../../../Users/lusin/AppData/Roaming/npm/node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6 - error TS2300: Duplicate identifier 'IteratorResult'.41 type IteratorResult = IteratorYieldResult | IteratorReturnResult;~~~~~~~~~~~~~~../node_modules/@types/node/index.d.ts:77:1177 interface IteratorResult { }~~~~~~~~~~~~~~'IteratorResult' was also declared here.../node_modules/@types/node/index.d.ts:77:11 - error TS2300: Duplicate identifier 'IteratorResult'.77 interface IteratorResult { }~~~~~~~~~~~~~~../../../../../Users/lusin/AppData/Roaming/npm/node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:641 type IteratorResult = IteratorYieldResult | IteratorReturnResult;~~~~~~~~~~~~~~'IteratorResult' was also declared here.Found 2 errors.
解决方案是在tsconfig.json的compilerOption中加入下面两项:
"skipLibCheck": true,"allowSyntheticDefaultImports": true
完整例子:
{"compilerOptions": {"module": "commonjs","target": "es6","outDir": "out","rootDir": "src","sourceMap": true,"skipLibCheck": true,"allowSyntheticDefaultImports": true},"include": ["src"],"exclude": ["node_modules", ".vscode-test"],
}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
