Skip to content

Using angular in a .d.ts file, I get “[ts] Cannot find namespace 'angular'” #8673

@bcherny

Description

@bcherny

Code:

    // ngimport.d.ts:
    export declare let $anchorScroll: angular.IAnchorScrollService;
    export declare let $cacheFactory: angular.ICacheFactoryService;
    export declare let $compile: angular.ICompileService;
    export declare let $controller: angular.IControllerService;
    export declare let $document: angular.IDocumentService;
    ...

Each of the angulars above throws an error in VSCode: [ts] Cannot find namespace 'angular' \ any.

And when I import ngimport from another project, I get Error TS2503: Cannot find namespace 'angular'

typings.json:

    {
      "ambientDependencies": {
        "angular": "registry:dt/angular#1.5.0+20160517064839",
        "jquery": "registry:dt/jquery#1.10.0+20160316155526"
      }
    }

tsconfig.json:

    {
      "compilerOptions": {
        "module": "es6",
        "moduleResolution": "node",
        "noImplicitAny": true,
        "preserveConstEnums": true,
        "outDir": ".",
        "sourceMap": false,
        "target": "es6"
      },
      "files": [
        "./typings/main.d.ts",
        "./ngimport.ts"
      ]
    }

Full source: https://github.com/bcherny/ngimport

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions