Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/lib/es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -992,12 +992,13 @@ interface ReadonlyArray<T> {
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: ReadonlyArray<T>[]): T[];
// TODO: https://github.com/Microsoft/TypeScript/issues/20454
concat(...items: (T[] | ReadonlyArray<T>)[]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: (T | ReadonlyArray<T>)[]): T[];
concat(...items: (T | T[] | ReadonlyArray<T>)[]): T[];
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
Expand Down Expand Up @@ -1113,12 +1114,12 @@ interface Array<T> {
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: ReadonlyArray<T>[]): T[];
concat(...items: (T[] | ReadonlyArray<T>)[]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: (T | ReadonlyArray<T>)[]): T[];
concat(...items: (T | T[] | ReadonlyArray<T>)[]): T[];
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/arrayConcat2.types
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ var a: string[] = [];

a.concat("hello", 'world');
>a.concat("hello", 'world') : string[]
>a.concat : { (...items: ReadonlyArray<string>[]): string[]; (...items: (string | ReadonlyArray<string>)[]): string[]; }
>a.concat : { (...items: (string[] | ReadonlyArray<string>)[]): string[]; (...items: (string | string[] | ReadonlyArray<string>)[]): string[]; }
>a : string[]
>concat : { (...items: ReadonlyArray<string>[]): string[]; (...items: (string | ReadonlyArray<string>)[]): string[]; }
>concat : { (...items: (string[] | ReadonlyArray<string>)[]): string[]; (...items: (string | string[] | ReadonlyArray<string>)[]): string[]; }
>"hello" : "hello"
>'world' : "world"

a.concat('Hello');
>a.concat('Hello') : string[]
>a.concat : { (...items: ReadonlyArray<string>[]): string[]; (...items: (string | ReadonlyArray<string>)[]): string[]; }
>a.concat : { (...items: (string[] | ReadonlyArray<string>)[]): string[]; (...items: (string | string[] | ReadonlyArray<string>)[]): string[]; }
>a : string[]
>concat : { (...items: ReadonlyArray<string>[]): string[]; (...items: (string | ReadonlyArray<string>)[]): string[]; }
>concat : { (...items: (string[] | ReadonlyArray<string>)[]): string[]; (...items: (string | string[] | ReadonlyArray<string>)[]): string[]; }
>'Hello' : "Hello"

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

b.concat('hello');
>b.concat('hello') : string[]
>b.concat : { (...items: ReadonlyArray<string>[]): string[]; (...items: (string | ReadonlyArray<string>)[]): string[]; }
>b.concat : { (...items: (string[] | ReadonlyArray<string>)[]): string[]; (...items: (string | string[] | ReadonlyArray<string>)[]): string[]; }
>b : string[]
>concat : { (...items: ReadonlyArray<string>[]): string[]; (...items: (string | ReadonlyArray<string>)[]): string[]; }
>concat : { (...items: (string[] | ReadonlyArray<string>)[]): string[]; (...items: (string | string[] | ReadonlyArray<string>)[]): string[]; }
>'hello' : "hello"

12 changes: 12 additions & 0 deletions tests/baselines/reference/arrayConcat3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//// [arrayConcat3.ts]
// TODO: remove lib hack when https://github.com/Microsoft/TypeScript/issues/20454 is fixed
type Fn<T extends object> = <U extends T>(subj: U) => U
function doStuff<T extends object, T1 extends T>(a: Array<Fn<T>>, b: Array<Fn<T1>>) {
b.concat(a);
}


//// [arrayConcat3.js]
function doStuff(a, b) {
b.concat(a);
}
32 changes: 32 additions & 0 deletions tests/baselines/reference/arrayConcat3.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
=== tests/cases/compiler/arrayConcat3.ts ===
// TODO: remove lib hack when https://github.com/Microsoft/TypeScript/issues/20454 is fixed
type Fn<T extends object> = <U extends T>(subj: U) => U
>Fn : Symbol(Fn, Decl(arrayConcat3.ts, 0, 0))
>T : Symbol(T, Decl(arrayConcat3.ts, 1, 8))
>U : Symbol(U, Decl(arrayConcat3.ts, 1, 29))
>T : Symbol(T, Decl(arrayConcat3.ts, 1, 8))
>subj : Symbol(subj, Decl(arrayConcat3.ts, 1, 42))
>U : Symbol(U, Decl(arrayConcat3.ts, 1, 29))
>U : Symbol(U, Decl(arrayConcat3.ts, 1, 29))

function doStuff<T extends object, T1 extends T>(a: Array<Fn<T>>, b: Array<Fn<T1>>) {
>doStuff : Symbol(doStuff, Decl(arrayConcat3.ts, 1, 55))
>T : Symbol(T, Decl(arrayConcat3.ts, 2, 17))
>T1 : Symbol(T1, Decl(arrayConcat3.ts, 2, 34))
>T : Symbol(T, Decl(arrayConcat3.ts, 2, 17))
>a : Symbol(a, Decl(arrayConcat3.ts, 2, 49))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Fn : Symbol(Fn, Decl(arrayConcat3.ts, 0, 0))
>T : Symbol(T, Decl(arrayConcat3.ts, 2, 17))
>b : Symbol(b, Decl(arrayConcat3.ts, 2, 65))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Fn : Symbol(Fn, Decl(arrayConcat3.ts, 0, 0))
>T1 : Symbol(T1, Decl(arrayConcat3.ts, 2, 34))

b.concat(a);
>b.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>b : Symbol(b, Decl(arrayConcat3.ts, 2, 65))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayConcat3.ts, 2, 49))
}

33 changes: 33 additions & 0 deletions tests/baselines/reference/arrayConcat3.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
=== tests/cases/compiler/arrayConcat3.ts ===
// TODO: remove lib hack when https://github.com/Microsoft/TypeScript/issues/20454 is fixed
type Fn<T extends object> = <U extends T>(subj: U) => U
>Fn : Fn<T>
>T : T
>U : U
>T : T
>subj : U
>U : U
>U : U

function doStuff<T extends object, T1 extends T>(a: Array<Fn<T>>, b: Array<Fn<T1>>) {
>doStuff : <T extends object, T1 extends T>(a: Fn<T>[], b: Fn<T1>[]) => void
>T : T
>T1 : T1
>T : T
>a : Fn<T>[]
>Array : T[]
>Fn : Fn<T>
>T : T
>b : Fn<T1>[]
>Array : T[]
>Fn : Fn<T>
>T1 : T1

b.concat(a);
>b.concat(a) : Fn<T1>[]
>b.concat : { (...items: (Fn<T1>[] | ReadonlyArray<Fn<T1>>)[]): Fn<T1>[]; (...items: (Fn<T1> | Fn<T1>[] | ReadonlyArray<Fn<T1>>)[]): Fn<T1>[]; }
>b : Fn<T1>[]
>concat : { (...items: (Fn<T1>[] | ReadonlyArray<Fn<T1>>)[]): Fn<T1>[]; (...items: (Fn<T1> | Fn<T1>[] | ReadonlyArray<Fn<T1>>)[]): Fn<T1>[]; }
>a : Fn<T>[]
}

4 changes: 2 additions & 2 deletions tests/baselines/reference/arrayConcatMap.types
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }])
>[].concat([{ a: 1 }], [{ a: 2 }]) .map(b => b.a) : any[]
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
>[].concat([{ a: 1 }], [{ a: 2 }]) : any[]
>[].concat : { (...items: ReadonlyArray<any>[]): any[]; (...items: any[]): any[]; }
>[].concat : { (...items: (any[] | ReadonlyArray<any>)[]): any[]; (...items: any[]): any[]; }
>[] : undefined[]
>concat : { (...items: ReadonlyArray<any>[]): any[]; (...items: any[]): any[]; }
>concat : { (...items: (any[] | ReadonlyArray<any>)[]): any[]; (...items: any[]): any[]; }
>[{ a: 1 }] : { a: number; }[]
>{ a: 1 } : { a: number; }
>a : number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray<B>'.
Types of property 'concat' are incompatible.
Type '{ (...items: ReadonlyArray<A>[]): A[]; (...items: (A | ReadonlyArray<A>)[]): A[]; }' is not assignable to type '{ (...items: ReadonlyArray<B>[]): B[]; (...items: (B | ReadonlyArray<B>)[]): B[]; }'.
Type '{ (...items: (A[] | ReadonlyArray<A>)[]): A[]; (...items: (A | A[] | ReadonlyArray<A>)[]): A[]; }' is not assignable to type '{ (...items: (B[] | ReadonlyArray<B>)[]): B[]; (...items: (B | B[] | ReadonlyArray<B>)[]): B[]; }'.
Type 'A[]' is not assignable to type 'B[]'.
Type 'A' is not assignable to type 'B'.
Property 'b' is missing in type 'A'.
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C<A>' is not assignable to type 'ReadonlyArray<B>'.
Types of property 'concat' are incompatible.
Type '{ (...items: ReadonlyArray<A>[]): A[]; (...items: (A | ReadonlyArray<A>)[]): A[]; }' is not assignable to type '{ (...items: ReadonlyArray<B>[]): B[]; (...items: (B | ReadonlyArray<B>)[]): B[]; }'.
Type '{ (...items: (A[] | ReadonlyArray<A>)[]): A[]; (...items: (A | A[] | ReadonlyArray<A>)[]): A[]; }' is not assignable to type '{ (...items: (B[] | ReadonlyArray<B>)[]): B[]; (...items: (B | B[] | ReadonlyArray<B>)[]): B[]; }'.
Type 'A[]' is not assignable to type 'B[]'.


Expand All @@ -27,7 +27,7 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T
~~~
!!! error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray<B>'.
!!! error TS2322: Types of property 'concat' are incompatible.
!!! error TS2322: Type '{ (...items: ReadonlyArray<A>[]): A[]; (...items: (A | ReadonlyArray<A>)[]): A[]; }' is not assignable to type '{ (...items: ReadonlyArray<B>[]): B[]; (...items: (B | ReadonlyArray<B>)[]): B[]; }'.
!!! error TS2322: Type '{ (...items: (A[] | ReadonlyArray<A>)[]): A[]; (...items: (A | A[] | ReadonlyArray<A>)[]): A[]; }' is not assignable to type '{ (...items: (B[] | ReadonlyArray<B>)[]): B[]; (...items: (B | B[] | ReadonlyArray<B>)[]): B[]; }'.
!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
!!! error TS2322: Property 'b' is missing in type 'A'.
Expand All @@ -39,6 +39,6 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T
~~~
!!! error TS2322: Type 'C<A>' is not assignable to type 'ReadonlyArray<B>'.
!!! error TS2322: Types of property 'concat' are incompatible.
!!! error TS2322: Type '{ (...items: ReadonlyArray<A>[]): A[]; (...items: (A | ReadonlyArray<A>)[]): A[]; }' is not assignable to type '{ (...items: ReadonlyArray<B>[]): B[]; (...items: (B | ReadonlyArray<B>)[]): B[]; }'.
!!! error TS2322: Type '{ (...items: (A[] | ReadonlyArray<A>)[]): A[]; (...items: (A | A[] | ReadonlyArray<A>)[]): A[]; }' is not assignable to type '{ (...items: (B[] | ReadonlyArray<B>)[]): B[]; (...items: (B | B[] | ReadonlyArray<B>)[]): B[]; }'.
!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'.

8 changes: 4 additions & 4 deletions tests/baselines/reference/concatError.types
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ fa = fa.concat([0]);
>fa = fa.concat([0]) : number[]
>fa : number[]
>fa.concat([0]) : number[]
>fa.concat : { (...items: ReadonlyArray<number>[]): number[]; (...items: (number | ReadonlyArray<number>)[]): number[]; }
>fa.concat : { (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }
>fa : number[]
>concat : { (...items: ReadonlyArray<number>[]): number[]; (...items: (number | ReadonlyArray<number>)[]): number[]; }
>concat : { (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }
>[0] : number[]
>0 : 0

fa = fa.concat(0);
>fa = fa.concat(0) : number[]
>fa : number[]
>fa.concat(0) : number[]
>fa.concat : { (...items: ReadonlyArray<number>[]): number[]; (...items: (number | ReadonlyArray<number>)[]): number[]; }
>fa.concat : { (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }
>fa : number[]
>concat : { (...items: ReadonlyArray<number>[]): number[]; (...items: (number | ReadonlyArray<number>)[]): number[]; }
>concat : { (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }
>0 : 0


Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/concatTuples.types
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ijs = ijs.concat([[3, 4], [5, 6]]);
>ijs = ijs.concat([[3, 4], [5, 6]]) : [number, number][]
>ijs : [number, number][]
>ijs.concat([[3, 4], [5, 6]]) : [number, number][]
>ijs.concat : { (...items: ReadonlyArray<[number, number]>[]): [number, number][]; (...items: ([number, number] | ReadonlyArray<[number, number]>)[]): [number, number][]; }
>ijs.concat : { (...items: ([number, number][] | ReadonlyArray<[number, number]>)[]): [number, number][]; (...items: ([number, number] | [number, number][] | ReadonlyArray<[number, number]>)[]): [number, number][]; }
>ijs : [number, number][]
>concat : { (...items: ReadonlyArray<[number, number]>[]): [number, number][]; (...items: ([number, number] | ReadonlyArray<[number, number]>)[]): [number, number][]; }
>concat : { (...items: ([number, number][] | ReadonlyArray<[number, number]>)[]): [number, number][]; (...items: ([number, number] | [number, number][] | ReadonlyArray<[number, number]>)[]): [number, number][]; }
>[[3, 4], [5, 6]] : [number, number][]
>[3, 4] : [number, number]
>3 : 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ function rebase(fn: (base: any, ...args: any[]) => any): (...args: any[]) => any
>apply : (this: Function, thisArg: any, argArray?: any) => any
>this : any
>[ this ].concat(args) : any[]
>[ this ].concat : { (...items: ReadonlyArray<any>[]): any[]; (...items: any[]): any[]; }
>[ this ].concat : { (...items: (any[] | ReadonlyArray<any>)[]): any[]; (...items: any[]): any[]; }
>[ this ] : any[]
>this : any
>concat : { (...items: ReadonlyArray<any>[]): any[]; (...items: any[]): any[]; }
>concat : { (...items: (any[] | ReadonlyArray<any>)[]): any[]; (...items: any[]): any[]; }
>args : any[]

};
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/intersectionTypeInference3.types
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ declare const b: Set<A>;
const c1 = Array.from(a).concat(Array.from(b));
>c1 : Nominal<"A", string>[]
>Array.from(a).concat(Array.from(b)) : Nominal<"A", string>[]
>Array.from(a).concat : { (...items: ReadonlyArray<Nominal<"A", string>>[]): Nominal<"A", string>[]; (...items: (Nominal<"A", string> | ReadonlyArray<Nominal<"A", string>>)[]): Nominal<"A", string>[]; }
>Array.from(a).concat : { (...items: (Nominal<"A", string>[] | ReadonlyArray<Nominal<"A", string>>)[]): Nominal<"A", string>[]; (...items: (Nominal<"A", string> | Nominal<"A", string>[] | ReadonlyArray<Nominal<"A", string>>)[]): Nominal<"A", string>[]; }
>Array.from(a) : Nominal<"A", string>[]
>Array.from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
>from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>a : Set<Nominal<"A", string>>
>concat : { (...items: ReadonlyArray<Nominal<"A", string>>[]): Nominal<"A", string>[]; (...items: (Nominal<"A", string> | ReadonlyArray<Nominal<"A", string>>)[]): Nominal<"A", string>[]; }
>concat : { (...items: (Nominal<"A", string>[] | ReadonlyArray<Nominal<"A", string>>)[]): Nominal<"A", string>[]; (...items: (Nominal<"A", string> | Nominal<"A", string>[] | ReadonlyArray<Nominal<"A", string>>)[]): Nominal<"A", string>[]; }
>Array.from(b) : Nominal<"A", string>[]
>Array.from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
Expand Down
Loading