Skip to content

for-of with map.keys() gives TS2495 #11209

Closed
@davidreher

Description

@davidreher

TypeScript Version: 2.0.3

Code

let map = new Map<string, string>();
map.set('hello', 'world');

for (let key of map.keys()) {
    console.log(key);
}

Expected behavior:
It should not throw.

Actual behavior:
It throws error TS2495: Type 'IterableIterator<string>' is not an array type or a string type.

tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es7",
      "scripthost"
    ],
    "moduleResolution": "node",
    "noImplicitAny": false,
    "preserveConstEnums": true,
    "pretty": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "ES5"
  }
}

cc: @Mischi

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions