Visual Studio Code complains that it “Cannot find namespace” for types defined in *.d.ts files

前端 未结 4 1251
甜味超标
甜味超标 2021-01-19 10:06

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

4条回答
  •  猫巷女王i
    2021-01-19 10:10

    Cannot find namespace 'ng'"

    Make sure the project contains no reference to declare module ng. Same for moment.

    Update

    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

提交回复
热议问题