Angular4 我应该使用 Iterable 的什么定义
Angular4 What definition of Iterable should I use
我已将我的应用程序升级到最新的 Angular 4 (beta-8) 版本。但是我一直有以下错误:
@angular\core\src\change_detection\differs\iterable_differs.d.ts:14: TS2304 Cannot find name 'Iterable'
我确实查看了变更日志并发现:
A definition of Iterable<T>
is now required to correctly compile Angular applications. Support for Iterable<T>
is not required at runtime but a type definition Iterable<T>
must be available.
我应该在这里使用什么作为 Iterable 定义?
编辑:
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"
}
按照他们的变更日志中所述的 migration,您应该将 es2015.iterable
作为库添加到 tsconfig.json
:
{
...,
"compilerOptions" : {
...,
"lib": ["es6", "dom", "es2015.iterable"]
}
}
我尝试了这个问题的公认答案,但它对我的情况不起作用。
就我而言,我在 main.ts
中添加了以下行
///<reference path="./../typings/globals/core-js/index.d.ts"/>
问题解决了,希望对大家有帮助。
我已将我的应用程序升级到最新的 Angular 4 (beta-8) 版本。但是我一直有以下错误:
@angular\core\src\change_detection\differs\iterable_differs.d.ts:14: TS2304 Cannot find name 'Iterable'
我确实查看了变更日志并发现:
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 定义?
编辑:
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"
}
按照他们的变更日志中所述的 migration,您应该将 es2015.iterable
作为库添加到 tsconfig.json
:
{
...,
"compilerOptions" : {
...,
"lib": ["es6", "dom", "es2015.iterable"]
}
}
我尝试了这个问题的公认答案,但它对我的情况不起作用。
就我而言,我在 main.ts
中添加了以下行///<reference path="./../typings/globals/core-js/index.d.ts"/>
问题解决了,希望对大家有帮助。