首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Angular4我应该使用什么定义?

Angular4我应该使用什么定义?
EN

Stack Overflow用户
提问于 2017-02-20 14:27:57
回答 2查看 990关注 0票数 1

我已经升级了我的应用程序到最新的角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

代码语言:javascript
复制
"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"
  }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-02-20 14:58:55

在他们的变更日志中说明的https://github.com/angular/angular/blob/master/CHANGELOG.md#400-beta6-2017-02-03之后,您应该在tsconfig.json中添加es2015.iterable作为库

代码语言:javascript
复制
{
  ...,
  "compilerOptions" : {
     ...,
     "lib": ["es6", "dom", "es2015.iterable"]
   }
}
票数 4
EN

Stack Overflow用户

发布于 2017-02-21 12:55:54

我试过这个问题的公认答案,但在我的情况下行不通。

在我的例子中,我在我的main.ts中添加了下面一行

代码语言:javascript
复制
///<reference path="./../typings/globals/core-js/index.d.ts"/>

解决了这个问题,希望这能帮到别人。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42347142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档