From 71f0d60b04ab0d72a7e2b05251ecfaa4ddf33052 Mon Sep 17 00:00:00 2001 From: septs Date: Wed, 11 Jun 2025 08:00:41 +0800 Subject: [PATCH] fix: allow readonly map entry constructor --- type-definitions/immutable.d.ts | 2 +- type-definitions/ts-tests/map.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/type-definitions/immutable.d.ts b/type-definitions/immutable.d.ts index 43119ccab6..5882a7b0ef 100644 --- a/type-definitions/immutable.d.ts +++ b/type-definitions/immutable.d.ts @@ -617,7 +617,7 @@ declare namespace Immutable { * but since Immutable Map keys can be of any type the argument to `get()` is * not altered. */ - function Map(collection?: Iterable<[K, V]>): Map; + function Map(collection?: Iterable): Map; function Map(obj: R): MapOf; function Map(obj: { [key: string]: V }): Map; function Map(obj: { [P in K]?: V }): Map; diff --git a/type-definitions/ts-tests/map.ts b/type-definitions/ts-tests/map.ts index 59f39eb36c..cd8fa7b237 100644 --- a/type-definitions/ts-tests/map.ts +++ b/type-definitions/ts-tests/map.ts @@ -10,6 +10,10 @@ test('#constructor', () => { expect(Map([['a', 'a']])).type.toBe>(); + expect(Map([] as ReadonlyArray)).type.toBe< + Map + >(); + expect(Map(List<[number, string]>([[1, 'a']]))).type.toBe< Map >();