VS2015 build of TypeScript gives "TS2304:Build cannot find angular" error despite presence of angular.d.ts file

I'm new to TypeScript and have hit problems building my first VS2015 solution which uses the AngularJS framework and the Toastr library.VS2015 is the RTM version running under Windows 10 Pro Edit...

I'm new to TypeScript and have hit problems building my first VS2015 solution which uses the AngularJS framework and the Toastr library.

VS2015 is the RTM version running under Windows 10 Pro Edition. TypeScript is version 1.6.2. Angular is version 1.5.0-beta.2

Attempts to reference angular or toastr in my TypeScript files give "TS2304: Build cannot find name 'angular'" (or 'toastr') errors when attempting to build the new project, despite having installed the appropriate d.ts files from Definitely Typed.

The angular library definition file angular.d.ts is there under the typings directory in a sub-directory named angularjs and includes the line:

declare var angular: angular.IAngularStatic; 

in the tsd.json file I see the following:

  "installed": {
    "angularjs/angular.d.ts": {
      "commit": "e48f0c7a0a5f9e9d35e9cfd7506461bab435cb49"
    },

I was originally getting the error with Resharper 10 but have suspended it to remove that from the possible causes, but I get the TS2304 error when I try and build even with Resharper disabled.

What have I missed? How can I get TypeScript to recognise the two installed type definition files so I can successfully build my project?

I fixed this by adding the following line at the top of my TypeScript source file: (the Stack Overflow editor is truncating what follows the three comment slashes in the line below, but after the three slashes is a 'reference path' statement in angular brackets pointing at the d.ts file) ///

The Pluralsight "TypeScript and AngularJS" course I used to learn TypeScript had not mentioned this "comment" command at all (I found it by googling the same issue raised as a problem with WebStorm). I had assumed that the reference in tsd.json should be enough for the TypeScript compiler to find the appropriate type specification descriptions, but apparently not! The course does assume VS Code rather than VS2015 for the IDE so maybe that is the issue?

Are you sure that you have include angular.js in your html? declare var angular means that angular variable is created outside from any ts file and d.ts is used to infrom typescript what angular variable has.

Translating... 0%