【发布时间】:2016-09-28 13:12:21
【问题描述】:
我正在尝试使用 tsconfig.json,这样我就可以避免在一堆文件的顶部。但我不断收到此错误:
[ts] 找不到命名空间“ng”。任何
我的tsconfig.json 文件如下所示:
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": false,
"target": "es2015",
"allowSyntheticDefaultImports": true
},
"files": [
"./typings/index.d.ts"
]
}
如您所见,我将其指向我的index.d.ts 文件,如下所示:
/// <reference path="globals/angular-ui-router/index.d.ts" />
/// <reference path="globals/angular/index.d.ts" />
/// <reference path="globals/jquery/index.d.ts" />
但是,如果我将此引用放在模块的顶部:
app.controller.js
/// <reference path="../../../../typings/index.d.ts" />
...
它识别ng 并给我它的类型。为什么这可能不起作用?
感谢任何帮助。提前致谢!
【问题讨论】:
-
如问题中所述,我使用的是
tsconfig.json文件。 -
您使用的是什么版本的打字稿? tsconfig.json 功能从 1.5 版开始添加。
-
我在 gulp 任务中使用打字稿。使用
gulp-typescript(2.13.5) 和tsify(0.16.0)。
标签: javascript angularjs typescript typescript-typings