Recently, I updated my project to utilize the final release of Angular 2 and also upgraded Visual Studio to use TypeScript 2.0.3 from the Tool -> Extensions and Updates manager.
I compile my TypeScript using Gulp, and it compiles without any errors. However, within Visual Studio, I am encountering numerous errors. The top three most common errors are:
Error TS2403: Subsequent variable declarations must have the same type. Variable 'httpVersionMinor' must be of type 'string', but here has type 'number'. index.d.ts
Error TS2300: Duplicate identifier 'export='. index.d.ts
Error TS2320: Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'. Named property 'emit' of types 'EventEmitter' and 'Server' are not identical. index.d.ts
Here is an excerpt from my tsconfig.json file:
{
"compilerOptions": {
"noImplicitAny": false,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"exclude": [
"node_modules",
"typings"
]
}
Furthermore, this is what my typings.json file looks like:
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160909174046"
}
}
Moreover, here is a snippet from my main.ts file:
/// <reference path="../typings/index.d.ts"/>
/// <reference path="../typings/tsd.d.ts"/>
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
// APP imports *****************************************************
import { AppModule } from './app/app.module';
// ENABLE PRODUCTION MODE
// enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule)
.catch((err: any) => console.error(err));
Issue:
If I remove this line from the top of my main.ts file:
reference path="../typings/index.d.ts"
The errors vanish in Visual Studio, but they reappear during compilation with gulp/npm.
Attempts Made:
- Tried uninstalling and reinstalling typings using npm
- Deleted the typings and node modules folder and ran npm install
- Updated Visual Studio's TypeScript version to 2.0.3
- Made sure there were no references to es6 shim from previous RC versions
Question
Could someone assist me in understanding why these errors only occur in Visual Studio when referencing the index.d.ts file or why the errors surface in npm when that reference is removed?