Angular2 typescript in Asp.Net Mvc 4, getting started

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?

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

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"
  ]
}