当我使用Visual Studio开发Angular 4应用程序时,我尝试安装和卸载一些Angular库。突然间我在visual studio中发现了以下编译错误
Severity Code Description Project File Line Suppression State
Error TS2300 Duplicate identifier 'PropertyKey'. TypeScript Virtual Projects C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\lib.es2015.core.d.ts 21 Active
Error TS2403 Subsequent variable declarations must have the same type. Variable 'prototype' must be of type 'WeakSet<object>', but here has type 'WeakSet<any>'. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 620 Active
Error TS2403 Subsequent variable declarations must have the same type. Variable 'prototype' must be of type 'WeakSet<object>', but here has type 'WeakSet<any>'. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 620 Active
Error TS2403 Subsequent variable declarations must have the same type. Variable 'prototype' must be of type 'WeakMap<object, any>', but here has type 'WeakMap<any, any>'. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 606 Active
Error TS2403 Subsequent variable declarations must have the same type. Variable 'prototype' must be of type 'WeakMap<object, any>', but here has type 'WeakMap<any, any>'. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 606 Active
Error TS2300 Duplicate identifier 'PropertyKey'. TypeScript Virtual Projects C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\lib.es2015.core.d.ts 21 Active
Error TS2300 Duplicate identifier 'PropertyKey'. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 7 Active
Error TS2300 Duplicate identifier 'PropertyKey'. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 7 Active
Error Build:Subsequent variable declarations must have the same type. Variable 'prototype' must be of type 'WeakSet<object>', but here has type 'WeakSet<any>'. XX XX\node_modules\@types\es6-shim\index.d.ts 620
Error Build:Subsequent variable declarations must have the same type. Variable 'prototype' must be of type 'WeakMap<object, any>', but here has type 'WeakMap<any, any>'. XX XX\node_modules\@types\es6-shim\index.d.ts 606
Error Build:Duplicate identifier 'PropertyKey'. XX C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.3\lib.es2015.core.d.ts 21
Error Build:Duplicate identifier 'PropertyKey'. XX XX\node_modules\@types\es6-shim\index.d.ts 7
Error Build:All declarations of 'value' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 11
Error Build:All declarations of 'size' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 561
Error Build:All declarations of 'size' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 581
Error Build:All declarations of 'prototype' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 498
Error Build:All declarations of 'prototype' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 570
Error Build:All declarations of 'prototype' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 591
Error Build:All declarations of 'prototype' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 606
Error Build:All declarations of 'prototype' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 620
Error Build:All declarations of 'MIN_SAFE_INTEGER' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 290
Error Build:All declarations of 'MAX_SAFE_INTEGER' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 283
Error Build:All declarations of 'flags' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 346
Error Build:All declarations of 'EPSILON' must have identical modifiers. XX XX\node_modules\@types\es6-shim\index.d.ts 248
Error TS2687 All declarations of 'value' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 11 Active
Error TS2687 All declarations of 'value' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 11 Active
Error TS2687 All declarations of 'size' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 561 Active
Error TS2687 All declarations of 'size' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 561 Active
Error TS2687 All declarations of 'size' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 581 Active
Error TS2687 All declarations of 'size' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 581 Active
Error TS2687 All declarations of 'prototype' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 498 Active
Error TS2687 All declarations of 'prototype' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 498 Active
Error TS2687 All declarations of 'prototype' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 570 Active
Error TS2687 All declarations of 'prototype' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 570 Active
Error TS2687 All declarations of 'prototype' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 591 Active
Error TS2687 All declarations of 'prototype' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 591 Active
Error TS2687 All declarations of 'prototype' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 606 Active
Error TS2687 All declarations of 'prototype' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 606 Active
Error TS2687 All declarations of 'prototype' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 620 Active
Error TS2687 All declarations of 'prototype' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 620 Active
Error TS2687 All declarations of 'MIN_SAFE_INTEGER' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 290 Active
Error TS2687 All declarations of 'MIN_SAFE_INTEGER' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 290 Active
Error TS2687 All declarations of 'MAX_SAFE_INTEGER' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 283 Active
Error TS2687 All declarations of 'MAX_SAFE_INTEGER' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 283 Active
Error TS2687 All declarations of 'flags' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 346 Active
Error TS2687 All declarations of 'flags' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 346 Active
Error TS2687 All declarations of 'EPSILON' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 248 Active
Error TS2687 All declarations of 'EPSILON' must have identical modifiers. TypeScript Virtual Projects XX\node_modules\@types\es6-shim\index.d.ts 248 Active
如何修复这些编译错误?
答案 0 :(得分:1)
我已修复了这些编译错误从我的visual studio项目中删除npm包并重新安装它们,如下所示
cd "{project folder path that contains package.json}"
npm install
答案 1 :(得分:0)
敲了好久我得到这个解决方案后,我也遇到了同样的问题
如果您已导入组件,请删除所有引用
我刚刚删除了一个参考
从'es6-shim'导入{对象};
它又开始工作了
好运:)