简体   繁体   English

Angular Typescript库突然无法在Visual Studio中编译

[英]Angular Typescript libraries suddenly not compiling in Visual Studio

While I was developing Angular 4 application using Visual Studio, I tried to install and uninstall some Angular libraries. 当我使用Visual Studio开发Angular 4应用程序时,我尝试安装和卸载一些Angular库。 And suddenly I found the following compilation errors in visual studio 突然我在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

How do I fix these compilation errors? 如何解决这些编译错误?

I have fixed these compilation errors by Deleting the npm packages from my visual studio project and re-install them again as following 我已通过从Visual Studio项目中删除npm软件包并按如下所示再次重新安装来修复了这些编译错误

  1. Go to web project folder and delete "node_modules" folder 转到Web项目文件夹,然后删除“ node_modules”文件夹
  2. Open windows command as administrator 以管理员身份打开Windows命令
  3. write cd "{project folder path that contains package.json}" cd "{project folder path that contains package.json}"
  4. then write npm install 然后写npm install

I was also getting the same issue after banging my head for so long I got this solution 敲了好久我也遇到了同样的问题

please remove any reference if you have imported in component 如果您已导入组件,请删除所有参考

I have just removed one reference 我刚刚删除了一个参考

import { Object } from 'es6-shim'; 从'es6-shim'导入{Object};

and it started to work again 然后又开始工作了

best of luck :) 祝你好运:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM