Skip to content

No overload matches this call. Overload 1 of 4, '(iterable?: Iterable<readonly [unknown, unknown]> | null | undefined): Map<unknown, unknown>' #56120

Closed
@albertkao9

Description

@albertkao9

🔎 Search Terms

"No overload matches this call" '(iterable?: Iterable<readonly [unknown, unknown]> | null | undefined): Map<unknown, unknown>'

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about this.

⏯ Playground Link

https://www.typescriptlang.org/play?#code/MYewdgzgLgBAlmADgV1gXhmApgdxgWQENEAKAbRjIHJjEAbLKgGioCcsATKgXScqoBGhMMMLMqATyx06IHDxjcAlAG4AsAChseIqTIA6QwhRRu+gLbESWMFFYSYaAHwwbdifvYA3LKwhYSJSCVIA

💻 Code

const input = new Map([ ['apple','red'], ['banana','yellow'] ]);
new Map([...input].map(entry => entry.reverse()));

🙁 Actual behavior

compile error:
No overload matches this call.
Overload 1 of 4, '(iterable?: Iterable<readonly [unknown, unknown]> | null | undefined): Map<unknown, unknown>', gave the following error.
Argument of type 'string[][]' is not assignable to parameter of type 'Iterable<readonly [unknown, unknown]>'.
The types returned by 'Symbol.iterator.next(...)' are incompatible between these types.
Type 'IteratorResult<string[], any>' is not assignable to type 'IteratorResult<readonly [unknown, unknown], any>'.
Type 'IteratorYieldResult<string[]>' is not assignable to type 'IteratorResult<readonly [unknown, unknown], any>'.
Type 'IteratorYieldResult<string[]>' is not assignable to type 'IteratorYieldResult<readonly [unknown, unknown]>'.
Type 'string[]' is not assignable to type 'readonly [unknown, unknown]'.
Target requires 2 element(s) but source may have fewer.
Overload 2 of 4, '(entries?: readonly (readonly [unknown, unknown])[] | null | undefined): Map<unknown, unknown>', gave the following error.
Argument of type 'string[][]' is not assignable to parameter of type 'readonly (readonly [unknown, unknown])[]'.
Type 'string[]' is not assignable to type 'readonly [unknown, unknown]'.

🙂 Expected behavior

No compile error

Additional information about the issue

This JavaScript code has no compile error at https://developer.mozilla.org/en-US/play .
i.e. It works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions