Skip to content

Construct new Map from Array results in error TS2345 #12483

@albohlabs

Description

@albohlabs

TypeScript Version: 2.1.1

Code

new Map([
  ['a', {
    prop: {}
  }],
  ['b', { }]
]);

Expected behavior:

Creates a new Map with the keys a and b.

Actual behavior:

Error:(10, 9) TS2345:Argument of type '((string | { prop: {}; })[] | {}[])[]' is not assignable to parameter of type 'IterableShim<[{}, {}]>'.
  Types of property '"_es6-shim iterator_"' are incompatible.
    Type '() => IterableIteratorShim<(string | { prop: {}; })[] | {}[]>' is not assignable to type '() => Iterator<[{}, {}]>'.
      Type 'IterableIteratorShim<(string | { prop: {}; })[] | {}[]>' is not assignable to type 'Iterator<[{}, {}]>'.
        Types of property 'next' are incompatible.
          Type '{ (value?: any): IteratorResult<(string | { prop: {}; })[] | {}[]>; (value?: any): IteratorResult...' is not assignable to type '{ (value?: any): IteratorResult<[{}, {}]>; (value?: any): IteratorResult<[{}, {}]>; (value?: any)...'.
            Type 'IteratorResult<(string | { prop: {}; })[] | {}[]>' is not assignable to type 'IteratorResult<[{}, {}]>'.
              Type '(string | { prop: {}; })[] | {}[]' is not assignable to type '[{}, {}]'.
                Type '(string | { prop: {}; })[]' is not assignable to type '[{}, {}]'.
                  Property '0' is missing in type '(string | { prop: {}; })[]'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions