Skip to content

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

Closed
Closed
@tiberiucorbu

Description

@tiberiucorbu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions