Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bcherny opened this issue May 18, 2016 · 3 comments
Closed
Labels
Question An issue which isn't directly actionable in code

Comments

@bcherny
Copy link

bcherny commented May 18, 2016

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

@bcherny bcherny changed the title Cannot import NPM module that uses external typings Using angular in a .d.ts file, I get “[ts] Cannot find namespace 'angular'” May 18, 2016
@RyanCavanaugh
Copy link
Member

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label May 18, 2016
@bcherny
Copy link
Author

bcherny commented May 18, 2016

For anyone who finds this in the future, this was actually a typings issue. Upgrading typings to 1.x fixed it.

@chriso86
Copy link

That link is a lie.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants