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

Loop with for ... of over a Map #14185

Closed
tiberiucorbu opened this issue Feb 20, 2017 · 2 comments
Closed

Loop with for ... of over a Map #14185

tiberiucorbu opened this issue Feb 20, 2017 · 2 comments
Labels
Fixed A PR has been merged for this issue

Comments

@tiberiucorbu
Copy link

tiberiucorbu commented Feb 20, 2017

TypeScript Version: 2.1.6

Code

let entries: Map<string, string[]> = new Map<string, string[]>();
entries.set('a', ['foo'])
for (let entry of entries.values()) {
// do something with the entry
}

Expected behavior:
Since Typescript is advertised as a superset of ES6 than expected is that it should support es6 features. Therefor for ... of should work properly with IterableIterator as described here : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map

Actual behavior:
Compilation fails

TS2495: Type 'IterableIterator<string[]>' is not an array type or a string type.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 20, 2017

This should be addressed by #12346 under --downlevelIteration. Make sure es2015 or es2015.iterable is part of your --lib arguments.

@mhegazy mhegazy closed this as completed Apr 20, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Apr 20, 2017
@mhegazy mhegazy added this to the TypeScript 2.3 milestone Apr 20, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants