小编Jan*_*ski的帖子

找不到名称空间“ ng”

我正在将简单的angular 1.6项目重写为打字稿。我已经声明了类型依赖,并且它们已经被编译和安装。尽管如此,我的服务中还是出现编译错误“找不到命名空间'ng'”。角度名称也无法识别。

屏幕截图

tsconfig.json

{
    "files": [
        "app/**/*.ts",
        "app/**/*.js",
        "main.js",
        "renderer.js"
    ],
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "declaration": false,
        "noImplicitAny": false,
        "allowJs": false,
        "rootDir": ".",
        "typeRoots": ["./typings"] 
    }
}
Run Code Online (Sandbox Code Playgroud)

Types.json

{
  "dependencies": {
    "angular": "registry:dt/angular#1.6.0+20170321201455"
  },
  "globalDependencies": {
    "jquery": "registry:dt/jquery#1.10.0+20170310222111"
  }
}
Run Code Online (Sandbox Code Playgroud)

服务

module Services {

    export interface IMyService {
    }

    export class MyService {

        http: ng.IHttpService;
        location: ng.ILocationService;

        constructor($http: ng.IHttpService, $location: ng.ILocationService) {
            this.http = $http;
            this.location = $location;
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

javascript angularjs typescript electron visual-studio-code

0
推荐指数
2
解决办法
7552
查看次数