From 0d40b8e0e2989310e0b34e9ce0935da68268afbf Mon Sep 17 00:00:00 2001 From: Ron Buckton <ron.buckton@microsoft.com> Date: Fri, 9 Jun 2023 16:32:36 -0400 Subject: [PATCH] Fix regression in WeakMap constructor type --- src/lib/es2015.collection.d.ts | 2 +- .../baselines/reference/dissallowSymbolAsWeakType.errors.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/es2015.collection.d.ts b/src/lib/es2015.collection.d.ts index 752d0500b0933..122e30666ab27 100644 --- a/src/lib/es2015.collection.d.ts +++ b/src/lib/es2015.collection.d.ts @@ -64,7 +64,7 @@ interface WeakMap<K extends WeakKey, V> { } interface WeakMapConstructor { - new <K extends WeakKey = WeakKey, V = any>(entries?: readonly [K, V][] | null): WeakMap<K, V>; + new <K extends WeakKey = WeakKey, V = any>(entries?: readonly (readonly [K, V])[] | null): WeakMap<K, V>; readonly prototype: WeakMap<WeakKey, any>; } declare var WeakMap: WeakMapConstructor; diff --git a/tests/baselines/reference/dissallowSymbolAsWeakType.errors.txt b/tests/baselines/reference/dissallowSymbolAsWeakType.errors.txt index 6cfa7e561749a..bb5a8b0daf840 100644 --- a/tests/baselines/reference/dissallowSymbolAsWeakType.errors.txt +++ b/tests/baselines/reference/dissallowSymbolAsWeakType.errors.txt @@ -21,7 +21,7 @@ dissallowSymbolAsWeakType.ts(8,12): error TS2769: No overload matches this call. Type '[symbol, false]' is not assignable to type 'readonly [object, boolean]'. Type at position 0 in source is not compatible with type at position 0 in target. Type 'symbol' is not assignable to type 'object'. - Overload 2 of 2, '(entries?: readonly [object, boolean][]): WeakMap<object, boolean>', gave the following error. + Overload 2 of 2, '(entries?: readonly (readonly [object, boolean])[]): WeakMap<object, boolean>', gave the following error. Type 'symbol' is not assignable to type 'object'. dissallowSymbolAsWeakType.ts(9,8): error TS2345: Argument of type 'symbol' is not assignable to parameter of type 'object'. dissallowSymbolAsWeakType.ts(10,8): error TS2345: Argument of type 'symbol' is not assignable to parameter of type 'object'. @@ -69,7 +69,7 @@ dissallowSymbolAsWeakType.ts(19,14): error TS2345: Argument of type 'symbol' is !!! error TS2769: Type '[symbol, false]' is not assignable to type 'readonly [object, boolean]'. !!! error TS2769: Type at position 0 in source is not compatible with type at position 0 in target. !!! error TS2769: Type 'symbol' is not assignable to type 'object'. -!!! error TS2769: Overload 2 of 2, '(entries?: readonly [object, boolean][]): WeakMap<object, boolean>', gave the following error. +!!! error TS2769: Overload 2 of 2, '(entries?: readonly (readonly [object, boolean])[]): WeakMap<object, boolean>', gave the following error. !!! error TS2769: Type 'symbol' is not assignable to type 'object'. wm.set(s, true); ~