javascriptangularjstypescripttypescript1.4

Unable to find 'ng' in module... - broken Intellisense?


When trying to reference external modules, Intellisense spits out an error along the lines of..

Could not find symbol 'ng' in global module

or..

Could not find symbol 'ng' in module 'App' // my main module

..even though I'm correctly referencing the typescript definitions (using definitelyTyped):

_references.ts

/// <reference path="../../typings/tsd.d.ts" />

declare var angular: ng.IAngularStatic; // unable to find in global module

SomeDirective.ts

/// <reference path="_references.ts" />

module App {
    export class SomeDirective implements ng.IDirective // unable to find in module 'App'
}

Interestingly, compiling the *.ts files with grunt-typescript works fine and the application runs without any problems.


Solution

  • You have "declare module ng" somewhere in your code base. Please change it to "declare module angular"

    Details : https://github.com/borisyankov/DefinitelyTyped/pull/3851#issue-60749247

    Update

    What I mean is search for declare module ng. There should be zero results (which I suspect is not the case for your codebase).

    Note: angular.d.ts now does declare module angular not declare module ng.

    https://github.com/borisyankov/DefinitelyTyped/blob/master/angularjs/angular.d.ts#L26