mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
lib Fix Part 1/6 – WeakMap constructor (#50449)
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
parent
0e357f510b
commit
57394450db
2
src/lib/es2015.collection.d.ts
vendored
2
src/lib/es2015.collection.d.ts
vendored
@ -64,7 +64,7 @@ interface WeakMap<K extends object, V> {
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new <K extends object = object, V = any>(entries?: readonly [K, V][] | null): WeakMap<K, V>;
|
||||
new <K extends object = object, V = any>(entries?: readonly (readonly [K, V])[] | null): WeakMap<K, V>;
|
||||
readonly prototype: WeakMap<object, any>;
|
||||
}
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
//// [mapConstructorOnReadonlyTuple.ts]
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
new Map(pairs);
|
||||
const pairs = [[{}, 1], [{}, 2]] as const;
|
||||
new Map(pairs);
|
||||
new WeakMap(pairs);
|
||||
|
||||
|
||||
//// [mapConstructorOnReadonlyTuple.js]
|
||||
const pairs = [['1', 1], ['2', 2]];
|
||||
const pairs = [[{}, 1], [{}, 2]];
|
||||
new Map(pairs);
|
||||
new WeakMap(pairs);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
=== tests/cases/compiler/mapConstructorOnReadonlyTuple.ts ===
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
const pairs = [[{}, 1], [{}, 2]] as const;
|
||||
>pairs : Symbol(pairs, Decl(mapConstructorOnReadonlyTuple.ts, 0, 5))
|
||||
>const : Symbol(const)
|
||||
|
||||
@ -7,3 +7,7 @@ new Map(pairs);
|
||||
>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>pairs : Symbol(pairs, Decl(mapConstructorOnReadonlyTuple.ts, 0, 5))
|
||||
|
||||
new WeakMap(pairs);
|
||||
>WeakMap : Symbol(WeakMap, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>pairs : Symbol(pairs, Decl(mapConstructorOnReadonlyTuple.ts, 0, 5))
|
||||
|
||||
|
||||
@ -1,17 +1,22 @@
|
||||
=== tests/cases/compiler/mapConstructorOnReadonlyTuple.ts ===
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
>pairs : readonly [readonly ["1", 1], readonly ["2", 2]]
|
||||
>[['1', 1], ['2', 2]] as const : readonly [readonly ["1", 1], readonly ["2", 2]]
|
||||
>[['1', 1], ['2', 2]] : readonly [readonly ["1", 1], readonly ["2", 2]]
|
||||
>['1', 1] : readonly ["1", 1]
|
||||
>'1' : "1"
|
||||
const pairs = [[{}, 1], [{}, 2]] as const;
|
||||
>pairs : readonly [readonly [{}, 1], readonly [{}, 2]]
|
||||
>[[{}, 1], [{}, 2]] as const : readonly [readonly [{}, 1], readonly [{}, 2]]
|
||||
>[[{}, 1], [{}, 2]] : readonly [readonly [{}, 1], readonly [{}, 2]]
|
||||
>[{}, 1] : readonly [{}, 1]
|
||||
>{} : {}
|
||||
>1 : 1
|
||||
>['2', 2] : readonly ["2", 2]
|
||||
>'2' : "2"
|
||||
>[{}, 2] : readonly [{}, 2]
|
||||
>{} : {}
|
||||
>2 : 2
|
||||
|
||||
new Map(pairs);
|
||||
>new Map(pairs) : Map<"1" | "2", 1 | 2>
|
||||
>new Map(pairs) : Map<{}, 1 | 2>
|
||||
>Map : MapConstructor
|
||||
>pairs : readonly [readonly ["1", 1], readonly ["2", 2]]
|
||||
>pairs : readonly [readonly [{}, 1], readonly [{}, 2]]
|
||||
|
||||
new WeakMap(pairs);
|
||||
>new WeakMap(pairs) : WeakMap<{}, 1 | 2>
|
||||
>WeakMap : WeakMapConstructor
|
||||
>pairs : readonly [readonly [{}, 1], readonly [{}, 2]]
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
// @target: es2015
|
||||
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
new Map(pairs);
|
||||
const pairs = [[{}, 1], [{}, 2]] as const;
|
||||
new Map(pairs);
|
||||
new WeakMap(pairs);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user