I created a new project using the gulp-angular Yeoman generator with language set to TypeScript. Then ran the Gulp build process and also opened the page in a web browser, w
I had the same problem; it appears typings was stripping the original definition file referencing the "ng" import.
Add this back to your original angular/index.d.ts file:
// Collapse angular into ng
import ng = angular;
Or better yet, place it in a ng.d.ts file so it's not overwritten by typings again.
Cannot find namespace 'ng'"
Make sure the project contains no reference to declare module ng
. Same for moment.
based on edit in the question:
Explicitely referencing the type definition files by adding the following to the top of navbar.directive.ts removes the problem
Please use a tsconfig.json
: https://basarat.gitbooks.io/typescript/content/docs/project/compilation-context.html
Adding a tsconfig.json
to the root of my VS Code project is what fixed the issue for me. Also, had to restart VS code. Here is what I put inside that file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true
}
}
For more info on the tsconfig.json
file, check out:
https://code.visualstudio.com/docs/languages/typescript
I found the following in a discreet location in the code. Likely put there to avoid type errors. Seems like vscode encountered this and redefined the global 'angular' variable as type of 'any'.
var angular = window['angular'];