Angular4我应该使用Iterable的什么定义 [英] Angular4 What definition of Iterable should I use
问题描述
我已经将我的应用程序升级到了最新的Angular 4(beta-8)版本.但是我仍然遇到以下错误:
I have upgraded my app to the latest Angular 4 (beta-8) version. However I keep having the following error :
@angular\core\src\change_detection\differs\iterable_differs.d.ts:14: TS2304 Cannot find name 'Iterable'
我确实查看了变更日志并发现:
I did look up the changelog and found :
现在需要
Iterable<T>
的定义才能正确编译Angular应用程序.在运行时不需要支持Iterable<T>
,但是类型定义Iterable<T>
必须可用.
A definition of
Iterable<T>
is now required to correctly compile Angular applications. Support forIterable<T>
is not required at runtime but a type definitionIterable<T>
must be available.
在这里,我应该使用什么作为Iterable定义?
What should I use as Iterable definition here ?
tsconfig.json
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"
}
推荐答案
Following the migration stated in their changelog you should add es2015.iterable
as a lib inside your tsconfig.json
:
{
...,
"compilerOptions" : {
...,
"lib": ["es6", "dom", "es2015.iterable"]
}
}
这篇关于Angular4我应该使用Iterable的什么定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!