我想用新的TS2和@types注册表使用Angular 1.x,但遇到问题。它看起来像@types不使用类型注册表所称的“全局”类型。我遇到以下错误:Angular 1.x with TypeScript 2.x,@types和SystemJS - 使用全局打印
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-typescrip pt来编译。我错过了什么?我可以不使用@types库来达到这个目的吗?
我最终放弃了打字。我试着这个语法,但仍然有错误。 –
尝试使用Lodash执行此操作时出现以下错误: System.import中的错误,无法引导。错误:(SystemJS)XHR误差(404未找到)加载的http://本地主机:3000/lodash \t错误:XHR错误(404未找到)加载的http://本地主机:3000/lodash \t错误加载HTTP:/ /172.16.95.136:3000/lodash从http:// localhost:3000/proj/src/app/app(匿名函数)@ localhost /:52 –