6
votes

I'm using the angular2 QUICKSTART and I have a problem where Visual Studio don't recognize Angular2 with typescript import Modules, in rest all it's fine:

enter image description here

It says:

Cannot find module 'angular2/platform/browser'

My app :

  • is compiling .ts files without errors
  • it runs in browser without errors
  • if I open the project in VS code it works fine, no errors in IDE

I know that typescript should read .d.ts file directly from node_modules --> angular2, but anyway I tried to add angular2 DefinitelyTyped and still not worked.

Atm I use VS 2013 update 5 with typescript 1.5 installed (I also tried with 1.75)

2
hah, indeed, maybe I should try the 2015 version :)tibbus
I'd also not bother with DefinitelyTyped any more, the typings there haven't been updated in months and wont any more, everything is provided by the npm package nowZyzle
Yeah. The angular2 definitions in DefinitelyTyped should probably be deletedbasarat
And your TS version is really old, and some of their typings use features from TS 1.7.x. You downgrade it, upgrade it again :DEric Martinez
Install the latest version of Visual Studio 2015. Then go to typescriptlang.org and download and install the latest typescript extension for VS. I highly recommend creating your a new project in ASP.NET 5 (it is a perfect environment to work with angular imo). Follow the instructions at angular.io to set up your project. You will be ready to rock and roll.brando

2 Answers

0
votes

Please right click on the visual studio project and click on the Properties option, Then select Typescript Build,default 'none' is selected, change it to 'CommonJs'.

If again any problem regarding 'experimentalDecorators' persists unload the project and add <TypeScriptExperimentalDecorators>true</TypeScriptExperimentalDecorators>statement inside the PropertyGroup tag.

Again problem exists on building the project such as 'could not find the name Map', 'could not find the name Promise', or 'could not find the name Set' try to change the target to 'es6' in the tsconfig.json

-3
votes

Solved by using Visual Studio 2015.