Kindly review the update below
I utilized the following package as a foundation for my VS Project -> https://github.com/AngularClass/angular2-webpack-starter
Everything ran smoothly in Visual Studio Code, but when I attempted to convert it into a Visual Studio 2017 Project (node.js web), some issues arose.
In Visual Studio, TypeScript definitions seem to be installed in a specific directory
C:\Users\MyUser\AppData\Local\Microsoft\TypeScript\node_modules\@types
In addition, I added @types/node in my package.json which created the appropriate node_modules folder.
Now, Visual Studio is displaying error code TS4090 (Conflicting definitions for 'node').
Is there a way, other than deleting the folder in \AppData, to instruct Visual Studio which @types it should utilize?
The complete setup of TypeScript is somewhat unclear to me... Does MSBuild identify an existing tsconfig.json? or do I need to configure it in the project-file as shown here?
UPDATE
I just realized that I was actually editing a .js file. As soon as I changed the extension to .ts, all warnings and errors disappeared. I was also encountering numerous typescript errors (such as TS2307, can't find module '@angular/core') before changing the extension from .js to .ts
The file simply had an import (from node)
import * as fs from 'fs';
Can someone please explain why these errors occurred? Why did a JS file result in over 200 typescript errors (some not even related to the above import)?
UPDATE2 the errors that are appearing include
- TS2403 - Subsequent Variable declarations must have the same type.
- TS2300 - Duplicate identifier 'PropertyKey'
- TS4090 - Conflicting definitions for 'node' found (in other words: found in
./node_modules
andC:\Users\MyUser\AppData\Local\Microsoft\TypeScript\node_modules\@types
All these errors are caused by d.ts
files in
C:\Users\MyUser\AppData\Local\Microsoft\TypeScript\node_modules\@types
or C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TypeScript\lib.es6.d.ts
As noted by Bowden Kelly, the root of these problems seems to be the definition files MS included in this directory
C:\Users\MyUser\AppData\Local\Microsoft\TypeScript\node_modules\@types
, once I install my own definition files in ./node_modules
, Visual Studio locates both definitions (if present) while editing JS files.
So the solution would either be:
- adhering to the MS Way
- or somehow excluding MS Directory