Skip to content
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 · 22 comments
Closed

Cannot find name 'Iterable'. #14595

naveedahmed1 opened this issue Feb 20, 2017 · 22 comments

Comments

@naveedahmed1
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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

@naveedahmed1
Copy link
Contributor Author

It increased the number of errors to 2297

@ericmartinezr
Copy link
Contributor

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

@naveedahmed1
Copy link
Contributor Author

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
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
Copy link
Contributor Author

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
Copy link
Contributor

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

@naveedahmed1
Copy link
Contributor Author

no worries! always appreciate your help :)

@pawelczak
Copy link

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

@xtianus79
Copy link

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

@xtianus79
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
Copy link

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
Copy link

Same issue.
adding

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

solved it.
Thanks @ericmartinezr !

@jsvini
Copy link

jsvini commented Aug 10, 2017

Upgrading typescript solved the issue for me.

@scriptmaster
Copy link

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

solved it.

@irejwanul
Copy link

"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
Copy link

ghost commented Nov 10, 2017

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

worked for me

@preist
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
Copy link

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

lukemarsden added a commit to dotmesh-io/jupyterlab-plugin that referenced this issue Jul 5, 2019
…d we have no lib/index.js) in the package any more, this seems to help by manual testing per angular/angular#14595
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests