Skip to content

Commit 4a470bd

Browse files
authored
Merge pull request #9997 from Microsoft/re-add-strict-concat-signature
Re-add strict concat signature
2 parents f06413b + e8bd372 commit 4a470bd

19 files changed

+88
-40
lines changed

src/lib/es5.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,11 @@ interface Array<T> {
11081108
* Removes the last element from an array and returns it.
11091109
*/
11101110
pop(): T | undefined;
1111+
/**
1112+
* Combines two or more arrays.
1113+
* @param items Additional items to add to the end of array1.
1114+
*/
1115+
concat(...items: T[][]): T[];
11111116
/**
11121117
* Combines two or more arrays.
11131118
* @param items Additional items to add to the end of array1.

tests/baselines/reference/arrayConcat2.symbols

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ var a: string[] = [];
33
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
44

55
a.concat("hello", 'world');
6-
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
6+
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
77
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
8-
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
8+
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
99

1010
a.concat('Hello');
11-
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
11+
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
1212
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
13-
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
13+
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
1414

1515
var b = new Array<string>();
1616
>b : Symbol(b, Decl(arrayConcat2.ts, 5, 3))
1717
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
1818

1919
b.concat('hello');
20-
>b.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
20+
>b.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
2121
>b : Symbol(b, Decl(arrayConcat2.ts, 5, 3))
22-
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
22+
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
2323

tests/baselines/reference/arrayConcat2.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ var a: string[] = [];
55

66
a.concat("hello", 'world');
77
>a.concat("hello", 'world') : string[]
8-
>a.concat : (...items: (string | string[])[]) => string[]
8+
>a.concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
99
>a : string[]
10-
>concat : (...items: (string | string[])[]) => string[]
10+
>concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
1111
>"hello" : string
1212
>'world' : string
1313

1414
a.concat('Hello');
1515
>a.concat('Hello') : string[]
16-
>a.concat : (...items: (string | string[])[]) => string[]
16+
>a.concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
1717
>a : string[]
18-
>concat : (...items: (string | string[])[]) => string[]
18+
>concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
1919
>'Hello' : string
2020

2121
var b = new Array<string>();
@@ -25,8 +25,8 @@ var b = new Array<string>();
2525

2626
b.concat('hello');
2727
>b.concat('hello') : string[]
28-
>b.concat : (...items: (string | string[])[]) => string[]
28+
>b.concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
2929
>b : string[]
30-
>concat : (...items: (string | string[])[]) => string[]
30+
>concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
3131
>'hello' : string
3232

tests/baselines/reference/arrayConcatMap.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
var x = [].concat([{ a: 1 }], [{ a: 2 }])
33
>x : Symbol(x, Decl(arrayConcatMap.ts, 0, 3))
44
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --))
5-
>[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
6-
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
5+
>[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
6+
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
77
>a : Symbol(a, Decl(arrayConcatMap.ts, 0, 20))
88
>a : Symbol(a, Decl(arrayConcatMap.ts, 0, 32))
99

tests/baselines/reference/arrayConcatMap.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }])
44
>[].concat([{ a: 1 }], [{ a: 2 }]) .map(b => b.a) : any[]
55
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
66
>[].concat([{ a: 1 }], [{ a: 2 }]) : any[]
7-
>[].concat : (...items: any[]) => any[]
7+
>[].concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
88
>[] : undefined[]
9-
>concat : (...items: any[]) => any[]
9+
>concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
1010
>[{ a: 1 }] : { a: number; }[]
1111
>{ a: 1 } : { a: number; }
1212
>a : number

tests/baselines/reference/concatError.symbols

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ var fa: number[];
1414

1515
fa = fa.concat([0]);
1616
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
17-
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
17+
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
1818
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
19-
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
19+
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
2020

2121
fa = fa.concat(0);
2222
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
23-
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
23+
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
2424
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
25-
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
25+
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
2626

2727

2828

tests/baselines/reference/concatError.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ fa = fa.concat([0]);
1616
>fa = fa.concat([0]) : number[]
1717
>fa : number[]
1818
>fa.concat([0]) : number[]
19-
>fa.concat : (...items: (number | number[])[]) => number[]
19+
>fa.concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; }
2020
>fa : number[]
21-
>concat : (...items: (number | number[])[]) => number[]
21+
>concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; }
2222
>[0] : number[]
2323
>0 : number
2424

2525
fa = fa.concat(0);
2626
>fa = fa.concat(0) : number[]
2727
>fa : number[]
2828
>fa.concat(0) : number[]
29-
>fa.concat : (...items: (number | number[])[]) => number[]
29+
>fa.concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; }
3030
>fa : number[]
31-
>concat : (...items: (number | number[])[]) => number[]
31+
>concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; }
3232
>0 : number
3333

3434

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//// [concatTuples.ts]
2+
let ijs: [number, number][] = [[1, 2]];
3+
ijs = ijs.concat([[3, 4], [5, 6]]);
4+
5+
6+
//// [concatTuples.js]
7+
var ijs = [[1, 2]];
8+
ijs = ijs.concat([[3, 4], [5, 6]]);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/concatTuples.ts ===
2+
let ijs: [number, number][] = [[1, 2]];
3+
>ijs : Symbol(ijs, Decl(concatTuples.ts, 0, 3))
4+
5+
ijs = ijs.concat([[3, 4], [5, 6]]);
6+
>ijs : Symbol(ijs, Decl(concatTuples.ts, 0, 3))
7+
>ijs.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
8+
>ijs : Symbol(ijs, Decl(concatTuples.ts, 0, 3))
9+
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
10+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/compiler/concatTuples.ts ===
2+
let ijs: [number, number][] = [[1, 2]];
3+
>ijs : [number, number][]
4+
>[[1, 2]] : [number, number][]
5+
>[1, 2] : [number, number]
6+
>1 : number
7+
>2 : number
8+
9+
ijs = ijs.concat([[3, 4], [5, 6]]);
10+
>ijs = ijs.concat([[3, 4], [5, 6]]) : [number, number][]
11+
>ijs : [number, number][]
12+
>ijs.concat([[3, 4], [5, 6]]) : [number, number][]
13+
>ijs.concat : { (...items: [number, number][][]): [number, number][]; (...items: ([number, number] | [number, number][])[]): [number, number][]; }
14+
>ijs : [number, number][]
15+
>concat : { (...items: [number, number][][]): [number, number][]; (...items: ([number, number] | [number, number][])[]): [number, number][]; }
16+
>[[3, 4], [5, 6]] : [number, number][]
17+
>[3, 4] : [number, number]
18+
>3 : number
19+
>4 : number
20+
>[5, 6] : [number, number]
21+
>5 : number
22+
>6 : number
23+

tests/baselines/reference/emitSkipsThisWithRestParameter.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function rebase(fn: (base: any, ...args: any[]) => any): (...args: any[]) => any
1515
>fn : Symbol(fn, Decl(emitSkipsThisWithRestParameter.ts, 0, 16))
1616
>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
1717
>this : Symbol(this, Decl(emitSkipsThisWithRestParameter.ts, 1, 20))
18-
>[ this ].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
18+
>[ this ].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
1919
>this : Symbol(this, Decl(emitSkipsThisWithRestParameter.ts, 1, 20))
20-
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
20+
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
2121
>args : Symbol(args, Decl(emitSkipsThisWithRestParameter.ts, 1, 30))
2222

2323
};

tests/baselines/reference/emitSkipsThisWithRestParameter.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ function rebase(fn: (base: any, ...args: any[]) => any): (...args: any[]) => any
1818
>apply : (this: Function, thisArg: any, argArray?: any) => any
1919
>this : any
2020
>[ this ].concat(args) : any[]
21-
>[ this ].concat : (...items: any[]) => any[]
21+
>[ this ].concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
2222
>[ this ] : any[]
2323
>this : any
24-
>concat : (...items: any[]) => any[]
24+
>concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
2525
>args : any[]
2626

2727
};

tests/baselines/reference/iteratorSpreadInArray7.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ var array: symbol[];
33
>array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 0, 3))
44

55
array.concat([...new SymbolIterator]);
6-
>array.concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --))
6+
>array.concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
77
>array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 0, 3))
8-
>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --))
8+
>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
99
>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38))
1010

1111
class SymbolIterator {

tests/baselines/reference/iteratorSpreadInArray7.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var array: symbol[];
44

55
array.concat([...new SymbolIterator]);
66
>array.concat([...new SymbolIterator]) : symbol[]
7-
>array.concat : (...items: (symbol | symbol[])[]) => symbol[]
7+
>array.concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; }
88
>array : symbol[]
9-
>concat : (...items: (symbol | symbol[])[]) => symbol[]
9+
>concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; }
1010
>[...new SymbolIterator] : symbol[]
1111
>...new SymbolIterator : symbol
1212
>new SymbolIterator : SymbolIterator

tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ class ListWrapper {
300300
>ListWrapper : Symbol(ListWrapper, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 38, 1))
301301
>a : Symbol(a, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 68, 40))
302302
>b : Symbol(b, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 68, 50))
303-
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
303+
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
304304
>a : Symbol(a, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 68, 40))
305-
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
305+
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
306306
>b : Symbol(b, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 68, 50))
307307

308308
static insert<T>(dit: typeof ListWrapper, list: T[], index: number, value: T) { list.splice(index, 0, value); }

tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ class ListWrapper {
348348
>a : any[]
349349
>b : any[]
350350
>a.concat(b) : any[]
351-
>a.concat : (...items: any[]) => any[]
351+
>a.concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
352352
>a : any[]
353-
>concat : (...items: any[]) => any[]
353+
>concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
354354
>b : any[]
355355

356356
static insert<T>(dit: typeof ListWrapper, list: T[], index: number, value: T) { list.splice(index, 0, value); }

tests/baselines/reference/underscoreTest1.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ var flat = _.reduceRight(list, (a, b) => a.concat(b), []);
7171
>list : Symbol(list, Decl(underscoreTest1_underscoreTests.ts, 13, 3))
7272
>a : Symbol(a, Decl(underscoreTest1_underscoreTests.ts, 14, 32))
7373
>b : Symbol(b, Decl(underscoreTest1_underscoreTests.ts, 14, 34))
74-
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
74+
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
7575
>a : Symbol(a, Decl(underscoreTest1_underscoreTests.ts, 14, 32))
76-
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
76+
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
7777
>b : Symbol(b, Decl(underscoreTest1_underscoreTests.ts, 14, 34))
7878

7979
var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0);

tests/baselines/reference/underscoreTest1.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ var flat = _.reduceRight(list, (a, b) => a.concat(b), []);
124124
>a : number[]
125125
>b : number[]
126126
>a.concat(b) : number[]
127-
>a.concat : (...items: (number | number[])[]) => number[]
127+
>a.concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; }
128128
>a : number[]
129-
>concat : (...items: (number | number[])[]) => number[]
129+
>concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; }
130130
>b : number[]
131131
>[] : undefined[]
132132

tests/cases/compiler/concatTuples.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let ijs: [number, number][] = [[1, 2]];
2+
ijs = ijs.concat([[3, 4], [5, 6]]);

0 commit comments

Comments
 (0)