2

我正在尝试使用 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并给我它的类型。为什么这可能不起作用?

任何帮助表示赞赏。提前致谢!

4

1 回答 1

0

app.controller.js

您的文件具有.js扩展名,因为它不是匹配文件的一部分tsconfig.json

快速解决方案

重命名.ts并列出您的文件tsconfig.json

于 2016-05-31T00:12:28.837 回答