【发布时间】:2017-08-13 18:36:51
【问题描述】:
我正在将简单的 Angular 1.6 项目重写为打字稿。我已经声明了类型依赖项,它们被编译和安装。尽管在我的服务中存在编译错误“找不到命名空间'ng'”。 Angular 名称也无法识别。
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"]
}
}
typings.json
{
"dependencies": {
"angular": "registry:dt/angular#1.6.0+20170321201455"
},
"globalDependencies": {
"jquery": "registry:dt/jquery#1.10.0+20170310222111"
}
}
service.ts
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;
}
}
}
【问题讨论】:
标签: javascript angularjs typescript visual-studio-code electron