Could not find "ng" in module ... - Broken Intellisense?

When trying to link to external modules, Intellisense spits an error along the lines.

Could not find symbol 'ng' in global module

or..

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

.. although I correctly refer to typescript definitions (using definitely Typed):

_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 * .ts files with grunt-typescript works fine and the application starts without problems.

+4
source share
2 answers

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

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

declare module ng. (, , ).

: angular.d.ts declare module angular declare module ng.

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

+2

. " angular" " angular", !

: https://github.com/DefinitelyTyped/DefinitelyTyped

angular.d.ts(///)

0

Source: https://habr.com/ru/post/1584129/


All Articles