我已经升级了我的应用程序到最新的角4 (beta-8)版本。但是,我始终有以下错误:
@angular\core\src\change_detection\differs\iterable_differs.d.ts:14: TS2304 Cannot find name 'Iterable'
我查了一下变化录,发现:
现在需要
Iterable<T>的定义才能正确编译角度应用程序。运行时不需要对Iterable<T>的支持,但必须提供类型定义Iterable<T>。
我在这里应该用什么来定义?
编辑:
tsconfig.json
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
/* for reading your ts source while debugging from a browser */
"sourceMap": true,
/* the following two settings are required for angular2 annotations to work*/
"emitDecoratorMetadata": true,
"experimentalDecorators":true,
/* noImplicitAny when you want your typescript to be fully typed */
"noImplicitAny":false,
"suppressImplicitAnyIndexErrors":true,
"noFallthroughCasesInSwitch":true,
"noImplicitReturns":true,
"outDir": "./target/ts"
}发布于 2017-02-20 14:58:55
在他们的变更日志中说明的https://github.com/angular/angular/blob/master/CHANGELOG.md#400-beta6-2017-02-03之后,您应该在tsconfig.json中添加es2015.iterable作为库
{
...,
"compilerOptions" : {
...,
"lib": ["es6", "dom", "es2015.iterable"]
}
}发布于 2017-02-21 12:55:54
我试过这个问题的公认答案,但在我的情况下行不通。
在我的例子中,我在我的main.ts中添加了下面一行
///<reference path="./../typings/globals/core-js/index.d.ts"/>解决了这个问题,希望这能帮到别人。
https://stackoverflow.com/questions/42347142
复制相似问题