New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find name 'Iterable'. #14595

Closed
naveedahmed1 opened this Issue Feb 20, 2017 · 21 comments

Comments

Projects
None yet
@naveedahmed1
Copy link

naveedahmed1 commented Feb 20, 2017

I'm submitting a ... (check one with "x")

[x ] bug report

Current behavior

I recently upgraded my angular 2 project to 4.0.0-beta.8. But when I try to compile, it throws below error:

node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts(15,48): error TS2304: Cannot find name 'Iterable'.

I have also seen a question with similar error on stackoverflow but no one has responded yet.

http://stackoverflow.com/questions/42252002/angular2-cannot-find-name-iterable-in-core

@ericmartinezr

This comment has been minimized.

Copy link
Contributor

ericmartinezr commented Feb 20, 2017

This has nothing to do with angular itself, it's a typing thing. How does your tsconfig look like? Make sure you're using ts2.0+

@naveedahmed1

This comment has been minimized.

Copy link

naveedahmed1 commented Feb 20, 2017

Thank you @ericmartinezr for your reply. I am using TypeScript 2.1.5 and below is my tsconfig:
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": true,
"sourceMap": false,
"target": "es5",
"outDir": "../content/app/"
},
"compileOnSave": true,
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}

and I am using Visual Studio 2015 with latest update 3

@ericmartinezr

This comment has been minimized.

Copy link
Contributor

ericmartinezr commented Feb 20, 2017

If you add lib: ["es2015", "es2015.iterable"] (as seen here) to your compilerOptions, does it work?

@naveedahmed1

This comment has been minimized.

Copy link

naveedahmed1 commented Feb 20, 2017

It increased the number of errors to 2297

@ericmartinezr

This comment has been minimized.

Copy link
Contributor

ericmartinezr commented Feb 20, 2017

lol... can you share a repo of your project? I can't look at it right now though

@naveedahmed1

This comment has been minimized.

Copy link

naveedahmed1 commented Feb 20, 2017

In my main.ts I removed

/// <reference path="./../typings/browser/ambient/es6-shim/index.d.ts" />

and added

///<reference path="./../typings/globals/core-js/index.d.ts"/>
which fixed the issue.

@ericmartinezr

This comment has been minimized.

Copy link
Contributor

ericmartinezr commented Feb 20, 2017

@naveedahmed1
I know you fixed it, but lets try something else, if it doesn't work just go back to what solved your issue.

Remove the line you posted above and add this in your tsconfig.json

"compierOptions" : {
     "lib" : ["es2015", "es2015.iterable", "dom"]
}

if that works, try removing es2015.iterable, if that doesn't work ignore everything :P

PS : Also consider using the @types form to declare your typings.
PS2: If you already solved your problem please close this issue, thanks.

@naveedahmed1

This comment has been minimized.

Copy link

naveedahmed1 commented Feb 20, 2017

With the changes you suggested, it now throws 26 errors including:

All declarations of 'size' must have identical modifiers
All declarations of 'prototype' must have identical modifiers.
@ericmartinezr

This comment has been minimized.

Copy link
Contributor

ericmartinezr commented Feb 20, 2017

@naveedahmed1 sorry then man, I'm out of ideas, stick to what works for you 👍

@naveedahmed1

This comment has been minimized.

Copy link

naveedahmed1 commented Feb 20, 2017

no worries! always appreciate your help :)

@pawelczak

This comment has been minimized.

Copy link

pawelczak commented Mar 26, 2017

I came across same issues. Fixed it by adding parameter in tsconfig.json "skipLibCheck": true.

@xtianus79

This comment has been minimized.

Copy link

xtianus79 commented Apr 18, 2017

@pawelczak is this a bug? The fix works but why

@xtianus79

This comment has been minimized.

Copy link

xtianus79 commented Apr 18, 2017

I added this and it fixed all my new typescript warnings.

"lib": ["es2015", "es2017", "dom"]

You can read this

lib manual

typescript lib origination doc

related issue and ref

@jspizziri

This comment has been minimized.

Copy link

jspizziri commented May 14, 2017

I was experiencing the same issue and the first PS from #14595 (comment) solved my issue. I simply reinstalled all my typings with the @types method.

@KoushikJit

This comment has been minimized.

Copy link

KoushikJit commented Jun 17, 2017

Same issue.
adding

"compierOptions" : {
     "lib" : ["es2015", "es2015.iterable", "dom"]
}

solved it.
Thanks @ericmartinezr !

@jsvini

This comment has been minimized.

Copy link

jsvini commented Aug 10, 2017

Upgrading typescript solved the issue for me.

@scriptmaster

This comment has been minimized.

Copy link

scriptmaster commented Sep 17, 2017

"compilerOptions": {
    "target": "es5",
    "lib": [ "es6", "dom" ]
}

solved it.

@irejwanul

This comment has been minimized.

Copy link

irejwanul commented Oct 31, 2017

"compilerOptions": {
"target": "es5",
"lib": [ "es2017", "dom" ]
}
The 'lib' option was mainly causing the error, and more specifically it is the "dom" lib option to add.

@ghost

This comment has been minimized.

Copy link

ghost commented Nov 10, 2017

"compilerOptions": {
"target": "es5",
"lib": [ "dom" ]
}

worked for me

@preist

This comment has been minimized.

Copy link

preist commented Dec 9, 2017

This worked for me:

npm i @types/node --save-dev`

The node typing contains the Iterable definition for --lib es5 it seems.

node_modules/@ types/node/index.d.ts

interface Iterable<T> { }
interface Iterator<T> {
    next(value?: any): IteratorResult<T>;
}
@kumaresan-subramani

This comment has been minimized.

Copy link

kumaresan-subramani commented Nov 9, 2018

I came across same issues. Fixed it by Adding “lib”: [ “es2015”, “dom” ] in tsconfig.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment