Angular4我应该使用Iterable的什么定义 [英] Angular4 What definition of Iterable should I use

查看:84
本文介绍了Angular4我应该使用Iterable的什么定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将我的应用程序升级到了最新的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 for Iterable<T> is not required at runtime but a type definition Iterable<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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆