mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-24 04:30:53 -06:00
parent
b762d6205e
commit
027d65a920
2
src/lib/es2015.collection.d.ts
vendored
2
src/lib/es2015.collection.d.ts
vendored
@ -10,7 +10,7 @@ interface Map<K, V> {
|
||||
|
||||
interface MapConstructor {
|
||||
new(): Map<any, any>;
|
||||
new<K, V>(entries?: ReadonlyArray<[K, V]> | null): Map<K, V>;
|
||||
new<K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): Map<K, V>;
|
||||
readonly prototype: Map<any, any>;
|
||||
}
|
||||
declare var Map: MapConstructor;
|
||||
|
||||
2
src/lib/es2015.iterable.d.ts
vendored
2
src/lib/es2015.iterable.d.ts
vendored
@ -129,7 +129,7 @@ interface ReadonlyMap<K, V> {
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new <K, V>(iterable: Iterable<[K, V]>): Map<K, V>;
|
||||
new <K, V>(iterable: Iterable<readonly [K, V]>): Map<K, V>;
|
||||
}
|
||||
|
||||
interface WeakMap<K extends object, V> { }
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
//// [mapConstructorOnReadonlyTuple.ts]
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
new Map(pairs);
|
||||
|
||||
//// [mapConstructorOnReadonlyTuple.js]
|
||||
const pairs = [['1', 1], ['2', 2]];
|
||||
new Map(pairs);
|
||||
@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/mapConstructorOnReadonlyTuple.ts ===
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
>pairs : Symbol(pairs, Decl(mapConstructorOnReadonlyTuple.ts, 0, 5))
|
||||
|
||||
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))
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
=== 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"
|
||||
>1 : 1
|
||||
>['2', 2] : readonly ["2", 2]
|
||||
>'2' : "2"
|
||||
>2 : 2
|
||||
|
||||
new Map(pairs);
|
||||
>new Map(pairs) : Map<"1" | "2", 1 | 2>
|
||||
>Map : MapConstructor
|
||||
>pairs : readonly [readonly ["1", 1], readonly ["2", 2]]
|
||||
|
||||
4
tests/cases/compiler/mapConstructorOnReadonlyTuple.ts
Normal file
4
tests/cases/compiler/mapConstructorOnReadonlyTuple.ts
Normal file
@ -0,0 +1,4 @@
|
||||
// @target: es2015
|
||||
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
new Map(pairs);
|
||||
Loading…
x
Reference in New Issue
Block a user