From afa94c527cd407fb0eed815d070f66406485a03d Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 22 Oct 2018 11:18:56 -0700 Subject: [PATCH] Un-consolidate overloads for Map and WeakMap (#28052) --- src/lib/es2015.collection.d.ts | 3 ++- src/lib/es2015.iterable.d.ts | 2 +- tests/baselines/reference/newMap.errors.txt | 8 ++++++++ tests/baselines/reference/newMap.js | 6 ++++++ tests/baselines/reference/newMap.symbols | 4 ++++ tests/baselines/reference/newMap.types | 5 +++++ tests/cases/compiler/newMap.ts | 2 ++ 7 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/newMap.errors.txt create mode 100644 tests/baselines/reference/newMap.js create mode 100644 tests/baselines/reference/newMap.symbols create mode 100644 tests/baselines/reference/newMap.types create mode 100644 tests/cases/compiler/newMap.ts diff --git a/src/lib/es2015.collection.d.ts b/src/lib/es2015.collection.d.ts index 46bb7af0c8fc7..34afa3d1b2b24 100644 --- a/src/lib/es2015.collection.d.ts +++ b/src/lib/es2015.collection.d.ts @@ -9,7 +9,8 @@ interface Map { } interface MapConstructor { - new (entries?: ReadonlyArray<[K, V]> | null): Map; + new(): Map; + new(entries?: ReadonlyArray<[K, V]> | null): Map; readonly prototype: Map; } declare var Map: MapConstructor; diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index 568d3596ddae3..f0a38dff3fe02 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -135,7 +135,7 @@ interface MapConstructor { interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; } interface Set { diff --git a/tests/baselines/reference/newMap.errors.txt b/tests/baselines/reference/newMap.errors.txt new file mode 100644 index 0000000000000..46668890b0714 --- /dev/null +++ b/tests/baselines/reference/newMap.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/newMap.ts(1,9): error TS2558: Expected 0-2 type arguments, but got 1. + + +==== tests/cases/compiler/newMap.ts (1 errors) ==== + new Map(); + ~~~~~~ +!!! error TS2558: Expected 0-2 type arguments, but got 1. + \ No newline at end of file diff --git a/tests/baselines/reference/newMap.js b/tests/baselines/reference/newMap.js new file mode 100644 index 0000000000000..9ab99fc7242c5 --- /dev/null +++ b/tests/baselines/reference/newMap.js @@ -0,0 +1,6 @@ +//// [newMap.ts] +new Map(); + + +//// [newMap.js] +new Map(); diff --git a/tests/baselines/reference/newMap.symbols b/tests/baselines/reference/newMap.symbols new file mode 100644 index 0000000000000..1ce51df496927 --- /dev/null +++ b/tests/baselines/reference/newMap.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/newMap.ts === +new Map(); +>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, --, --)) + diff --git a/tests/baselines/reference/newMap.types b/tests/baselines/reference/newMap.types new file mode 100644 index 0000000000000..d3fab45ccc0fd --- /dev/null +++ b/tests/baselines/reference/newMap.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/newMap.ts === +new Map(); +>new Map() : any +>Map : MapConstructor + diff --git a/tests/cases/compiler/newMap.ts b/tests/cases/compiler/newMap.ts new file mode 100644 index 0000000000000..ab7040e11d98b --- /dev/null +++ b/tests/cases/compiler/newMap.ts @@ -0,0 +1,2 @@ +// @lib: es6 +new Map();