After following the Angular2 TS Quickstart guide, I noticed duplicate files scattered across various folders in my project.
For browser:
typings/browser
node_modules/angular2/typings/browser
Regarding es6-shim:
node_modules/angular2/typings/es6-shim
typings/browser/ambient/es6-shim
typings/main/ambient/es6-shim
This duplication leads to errors like Duplicate Identifier during the build process.
How can we prevent or suppress TS from flagging duplicate identifier errors?
Even though I've excluded node_modules from the list, TSD still includes them back because of using Angular2 in my includes section and moduleResolution set to "node". Changing it to "classic" presents other issues.
This is the content of my tsconfig.json file:
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "./dist"
},
"exclude": [
"bower_components",
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
UPDATE 1
Below is my appcomponent.ts file:
///<reference path="../../node_modules/angular2/typings/browser.d.ts"/>
import {bootstrap} from 'angular2/platform/browser';
import {LocationComponent} from '../location/components/locationcomponent';
import {VideosComponent} from '../videos/components/videoscomponent';
bootstrap(LocationComponent, [])
.catch(err => console.error(err));
bootstrap(VideosComponent, [])
.catch(err => console.error(err));
UPDATE 2
This snippet shows my web project file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
(...)
UPDATE 3
My exploration revealed that setting up Angular2 in Visual Studio 2015 demands a different approach. I followed the guidelines in Starting Angular 2 in ASP.NET 5 with TypeScript using Visual Studio 2015 and successfully resolved the build issues.