Skip to content

Commit

Permalink
Un-consolidate overloads for Map and WeakMap (#28052)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy authored Oct 22, 2018
1 parent 8e0142d commit afa94c5
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib/es2015.collection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ interface Map<K, V> {
}

interface MapConstructor {
new <K = any, V = any>(entries?: ReadonlyArray<[K, V]> | null): Map<K, V>;
new(): Map<any, any>;
new<K, V>(entries?: ReadonlyArray<[K, V]> | null): Map<K, V>;
readonly prototype: Map<any, any>;
}
declare var Map: MapConstructor;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/es2015.iterable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ interface MapConstructor {
interface WeakMap<K extends object, V> { }

interface WeakMapConstructor {
new <K extends object = object, V = any>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
new <K extends object, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
}

interface Set<T> {
Expand Down
8 changes: 8 additions & 0 deletions tests/baselines/reference/newMap.errors.txt
Original file line number Diff line number Diff line change
@@ -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<string>();
~~~~~~
!!! error TS2558: Expected 0-2 type arguments, but got 1.

6 changes: 6 additions & 0 deletions tests/baselines/reference/newMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//// [newMap.ts]
new Map<string>();


//// [newMap.js]
new Map();
4 changes: 4 additions & 0 deletions tests/baselines/reference/newMap.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=== tests/cases/compiler/newMap.ts ===
new Map<string>();
>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, --, --))

5 changes: 5 additions & 0 deletions tests/baselines/reference/newMap.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== tests/cases/compiler/newMap.ts ===
new Map<string>();
>new Map<string>() : any
>Map : MapConstructor

2 changes: 2 additions & 0 deletions tests/cases/compiler/newMap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @lib: es6
new Map<string>();

0 comments on commit afa94c5

Please sign in to comment.