Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
674 views
in Technique[技术] by (71.8m points)

angular - Angular4 What definition of Iterable should I use

I have upgraded my app to the latest Angular 4 (beta-8) version. However I keep having the following error :

@angularcoresrcchange_detectiondiffersiterable_differs.d.ts:14: TS2304 Cannot find name 'Iterable'

I did look up the changelog and found :

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.

What should I use as Iterable definition here ?

EDIT:

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"
  }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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"]
   }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...