【发布时间】:2017-04-01 13:12:08
【问题描述】:
我正在尝试将 Angular 1.x 与新的 TS2 和 @types 注册表一起使用,但遇到了问题。看起来@types 不使用类型注册表称为“全局”类型的内容。我遇到了以下错误:
error TS2686: 'angular' refers to a UMD global, but the current file is a module. Consider adding an import instead.
角码如下:
import "angular";
import "angular-route";
const app = angular.module("charter-app", ["ui.bootstrap", "ui.router", "templates", "charter-app.controllers"]);
tsconfig.json:
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"mapRoot": "./",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5",
"inlineSources": true,
"removeComments": false,
"noImplicitAny": false,
"typeRoots": [ "node_modules/@types/" ],
"types": [ "angular", "angular-ui-bootstrap", "angular-ui-router" ],
"outFile": "app.js"
}
}
尝试使用以下
"devDependencies": {
"@types/angular": "^1.5.20",
"@types/angular-ui-bootstrap": "^0.13.35",
"@types/angular-ui-router": "^1.1.34",
我正在使用 gulp-typescript 进行编译。我错过了什么?我不能为此目的使用@types 库吗?
【问题讨论】:
标签: angularjs typescript typescript-typings typescript2.0