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
Crossposted at http://stackoverflow.com/questions/37310548/using-angular-in-a-d-ts-file-i-get-ts-cannot-find-namespace-angular , so let's answer there.
For anyone who finds this in the future, this was actually a typings issue. Upgrading typings to 1.x fixed it.
That link is a lie.