I'm not sure how to get started with Angular2 in typescript, Visual Studio 2015 for Asp.Net MVC 4

I have a typescript file which includes this

import { bootstrap } from 'angular2/platform/browser';

I then use nuget to get angular2.TypeScript.DefinitelyTyped

A compile now gives me -a lot- of errors, e.g.

Build: Cannot find module 'angular2/platform/browser'

and a few thousand of these errors

Build: Duplicate identifier 'SetterFn'

which are presumably because there are lots of versions of angular ts files present

All the answers I find on the web reference tsconfig.json and Asp.Net Mvc 5/Core

Where to start with this?

share|improve this question
    
use npm and typings from npm to manage the definitelyTyped typings . Nuget lacks behind the typings to manage them . Nuget typings are always behind the original github releases – Joy Apr 10 at 8:28
    
npmjs.com/package/typings – Joy Apr 10 at 8:29
    
I've managed to get away with not using npm up until now, if I do go down this road won't there still be multiple versions of angular2, alpha26, 28, 30, etc. how does typescript know which one to use? – tony Apr 10 at 8:36

The issue is that the typings install brings in two versions of the typings, so you will see browser.d.ts and main.d.ts under the typings folder.

When TypeScript sees both you get the Duplicate identifier error. This is a source of confusion IMO, but the fix is to remove one of them. Either by deleting the file (and folder with same name) or listing it as an exclude in your tsconfig.json.

For front end projects like Angular in the browser I would remove main.d.ts

Example of tsconfig exclude:

{
  "exclude": [
    "typings/main.d.ts",
    "typings/main"
  ]
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.