mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-12 01:48:33 -05:00
Hack to allow concat to work even when an Array isn't assignable to ReadonlyArray (#20455)
This commit is contained in:
9
src/lib/es5.d.ts
vendored
9
src/lib/es5.d.ts
vendored
@@ -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.
|
||||
@@ -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.
|
||||
|
||||
@@ -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>();
|
||||
@@ -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
tests/baselines/reference/arrayConcat3.js
Normal file
12
tests/baselines/reference/arrayConcat3.js
Normal file
@@ -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
tests/baselines/reference/arrayConcat3.symbols
Normal file
32
tests/baselines/reference/arrayConcat3.symbols
Normal file
@@ -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
tests/baselines/reference/arrayConcat3.types
Normal file
33
tests/baselines/reference/arrayConcat3.types
Normal file
@@ -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,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
|
||||
|
||||
@@ -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[]'.
|
||||
|
||||
|
||||
@@ -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'.
|
||||
@@ -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[]'.
|
||||
|
||||
@@ -15,9 +15,9 @@ 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
|
||||
|
||||
@@ -25,9 +25,9 @@ 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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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[]
|
||||
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(15,14): error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | ReadonlyArray<number>'.
|
||||
tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(15,14): error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[] | ReadonlyArray<number>'.
|
||||
Type 'symbol[]' is not assignable to type 'ReadonlyArray<number>'.
|
||||
Types of property 'concat' are incompatible.
|
||||
Type '{ (...items: ReadonlyArray<symbol>[]): symbol[]; (...items: (symbol | ReadonlyArray<symbol>)[]): symbol[]; }' is not assignable to type '{ (...items: ReadonlyArray<number>[]): number[]; (...items: (number | ReadonlyArray<number>)[]): number[]; }'.
|
||||
Type '{ (...items: (symbol[] | ReadonlyArray<symbol>)[]): symbol[]; (...items: (symbol | symbol[] | ReadonlyArray<symbol>)[]): symbol[]; }' is not assignable to type '{ (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }'.
|
||||
Types of parameters 'items' and 'items' are incompatible.
|
||||
Type 'ReadonlyArray<number>' is not assignable to type 'ReadonlyArray<symbol>'.
|
||||
Type 'number' is not assignable to type 'symbol'.
|
||||
Type 'number[] | ReadonlyArray<number>' is not assignable to type 'symbol[] | ReadonlyArray<symbol>'.
|
||||
Type 'number[]' is not assignable to type 'symbol[] | ReadonlyArray<symbol>'.
|
||||
Type 'number[]' is not assignable to type 'ReadonlyArray<symbol>'.
|
||||
Types of property 'concat' are incompatible.
|
||||
Type '{ (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }' is not assignable to type '{ (...items: (symbol[] | ReadonlyArray<symbol>)[]): symbol[]; (...items: (symbol | symbol[] | ReadonlyArray<symbol>)[]): symbol[]; }'.
|
||||
Types of parameters 'items' and 'items' are incompatible.
|
||||
Type 'symbol[] | ReadonlyArray<symbol>' is not assignable to type 'number[] | ReadonlyArray<number>'.
|
||||
Type 'symbol[]' is not assignable to type 'number[] | ReadonlyArray<number>'.
|
||||
Type 'symbol[]' is not assignable to type 'ReadonlyArray<number>'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts (1 errors) ====
|
||||
@@ -24,10 +31,17 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(15,14): error TS234
|
||||
var array: number[] = [0, 1];
|
||||
array.concat([...new SymbolIterator]);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | ReadonlyArray<number>'.
|
||||
!!! error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[] | ReadonlyArray<number>'.
|
||||
!!! error TS2345: Type 'symbol[]' is not assignable to type 'ReadonlyArray<number>'.
|
||||
!!! error TS2345: Types of property 'concat' are incompatible.
|
||||
!!! error TS2345: Type '{ (...items: ReadonlyArray<symbol>[]): symbol[]; (...items: (symbol | ReadonlyArray<symbol>)[]): symbol[]; }' is not assignable to type '{ (...items: ReadonlyArray<number>[]): number[]; (...items: (number | ReadonlyArray<number>)[]): number[]; }'.
|
||||
!!! error TS2345: Type '{ (...items: (symbol[] | ReadonlyArray<symbol>)[]): symbol[]; (...items: (symbol | symbol[] | ReadonlyArray<symbol>)[]): symbol[]; }' is not assignable to type '{ (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }'.
|
||||
!!! error TS2345: Types of parameters 'items' and 'items' are incompatible.
|
||||
!!! error TS2345: Type 'ReadonlyArray<number>' is not assignable to type 'ReadonlyArray<symbol>'.
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'symbol'.
|
||||
!!! error TS2345: Type 'number[] | ReadonlyArray<number>' is not assignable to type 'symbol[] | ReadonlyArray<symbol>'.
|
||||
!!! error TS2345: Type 'number[]' is not assignable to type 'symbol[] | ReadonlyArray<symbol>'.
|
||||
!!! error TS2345: Type 'number[]' is not assignable to type 'ReadonlyArray<symbol>'.
|
||||
!!! error TS2345: Types of property 'concat' are incompatible.
|
||||
!!! error TS2345: Type '{ (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }' is not assignable to type '{ (...items: (symbol[] | ReadonlyArray<symbol>)[]): symbol[]; (...items: (symbol | symbol[] | ReadonlyArray<symbol>)[]): symbol[]; }'.
|
||||
!!! error TS2345: Types of parameters 'items' and 'items' are incompatible.
|
||||
!!! error TS2345: Type 'symbol[] | ReadonlyArray<symbol>' is not assignable to type 'number[] | ReadonlyArray<number>'.
|
||||
!!! error TS2345: Type 'symbol[]' is not assignable to type 'number[] | ReadonlyArray<number>'.
|
||||
!!! error TS2345: Type 'symbol[]' is not assignable to type 'ReadonlyArray<number>'.
|
||||
@@ -38,9 +38,9 @@ var array: number[] = [0, 1];
|
||||
|
||||
array.concat([...new SymbolIterator]);
|
||||
>array.concat([...new SymbolIterator]) : any
|
||||
>array.concat : { (...items: ReadonlyArray<number>[]): number[]; (...items: (number | ReadonlyArray<number>)[]): number[]; }
|
||||
>array.concat : { (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }
|
||||
>array : number[]
|
||||
>concat : { (...items: ReadonlyArray<number>[]): number[]; (...items: (number | ReadonlyArray<number>)[]): number[]; }
|
||||
>concat : { (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }
|
||||
>[...new SymbolIterator] : symbol[]
|
||||
>...new SymbolIterator : symbol
|
||||
>new SymbolIterator : SymbolIterator
|
||||
|
||||
@@ -35,9 +35,9 @@ var array: symbol[];
|
||||
|
||||
array.concat([...new SymbolIterator]);
|
||||
>array.concat([...new SymbolIterator]) : symbol[]
|
||||
>array.concat : { (...items: ReadonlyArray<symbol>[]): symbol[]; (...items: (symbol | ReadonlyArray<symbol>)[]): symbol[]; }
|
||||
>array.concat : { (...items: (symbol[] | ReadonlyArray<symbol>)[]): symbol[]; (...items: (symbol | symbol[] | ReadonlyArray<symbol>)[]): symbol[]; }
|
||||
>array : symbol[]
|
||||
>concat : { (...items: ReadonlyArray<symbol>[]): symbol[]; (...items: (symbol | ReadonlyArray<symbol>)[]): symbol[]; }
|
||||
>concat : { (...items: (symbol[] | ReadonlyArray<symbol>)[]): symbol[]; (...items: (symbol | symbol[] | ReadonlyArray<symbol>)[]): symbol[]; }
|
||||
>[...new SymbolIterator] : symbol[]
|
||||
>...new SymbolIterator : symbol
|
||||
>new SymbolIterator : SymbolIterator
|
||||
|
||||
@@ -424,14 +424,14 @@ module TypeScript {
|
||||
|
||||
return this.primaryTable.getAllKeys().concat(this.secondaryTable.getAllKeys());
|
||||
>this.primaryTable.getAllKeys().concat(this.secondaryTable.getAllKeys()) : string[]
|
||||
>this.primaryTable.getAllKeys().concat : { (...items: ReadonlyArray<string>[]): string[]; (...items: (string | ReadonlyArray<string>)[]): string[]; }
|
||||
>this.primaryTable.getAllKeys().concat : { (...items: (string[] | ReadonlyArray<string>)[]): string[]; (...items: (string | string[] | ReadonlyArray<string>)[]): string[]; }
|
||||
>this.primaryTable.getAllKeys() : string[]
|
||||
>this.primaryTable.getAllKeys : () => string[]
|
||||
>this.primaryTable : IHashTable
|
||||
>this : this
|
||||
>primaryTable : IHashTable
|
||||
>getAllKeys : () => string[]
|
||||
>concat : { (...items: ReadonlyArray<string>[]): string[]; (...items: (string | ReadonlyArray<string>)[]): string[]; }
|
||||
>concat : { (...items: (string[] | ReadonlyArray<string>)[]): string[]; (...items: (string | string[] | ReadonlyArray<string>)[]): string[]; }
|
||||
>this.secondaryTable.getAllKeys() : string[]
|
||||
>this.secondaryTable.getAllKeys : () => string[]
|
||||
>this.secondaryTable : IHashTable
|
||||
|
||||
@@ -4868,9 +4868,9 @@ module Harness {
|
||||
>lines = lines.concat(v.file.lines) : any[]
|
||||
>lines : any[]
|
||||
>lines.concat(v.file.lines) : any[]
|
||||
>lines.concat : { (...items: ReadonlyArray<any>[]): any[]; (...items: any[]): any[]; }
|
||||
>lines.concat : { (...items: (any[] | ReadonlyArray<any>)[]): any[]; (...items: any[]): any[]; }
|
||||
>lines : any[]
|
||||
>concat : { (...items: ReadonlyArray<any>[]): any[]; (...items: any[]): any[]; }
|
||||
>concat : { (...items: (any[] | ReadonlyArray<any>)[]): any[]; (...items: any[]): any[]; }
|
||||
>v.file.lines : string[]
|
||||
>v.file : WriterAggregator
|
||||
>v : { filename: string; file: WriterAggregator; }
|
||||
|
||||
@@ -87,7 +87,7 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
>p1 : T
|
||||
|
||||
var {...r2} = p2; // OK
|
||||
>r2 : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; push(...items: T[]): number; pop(): T; concat(...items: ReadonlyArray<T>[]): T[]; concat(...items: (T | ReadonlyArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>r2 : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; push(...items: T[]): number; pop(): T; concat(...items: (T[] | ReadonlyArray<T>)[]): T[]; concat(...items: (T | T[] | ReadonlyArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>p2 : T[]
|
||||
|
||||
var {...r3} = t; // Error, generic type paramter
|
||||
|
||||
@@ -89,8 +89,8 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
>p1 : T
|
||||
|
||||
var o2 = { ...p2 }; // OK
|
||||
>o2 : { [x: number]: T; length: number; toString(): string; toLocaleString(): string; push(...items: T[]): number; pop(): T; concat(...items: ReadonlyArray<T>[]): T[]; concat(...items: (T | ReadonlyArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>{ ...p2 } : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; push(...items: T[]): number; pop(): T; concat(...items: ReadonlyArray<T>[]): T[]; concat(...items: (T | ReadonlyArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>o2 : { [x: number]: T; length: number; toString(): string; toLocaleString(): string; push(...items: T[]): number; pop(): T; concat(...items: (T[] | ReadonlyArray<T>)[]): T[]; concat(...items: (T | T[] | ReadonlyArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>{ ...p2 } : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; push(...items: T[]): number; pop(): T; concat(...items: (T[] | ReadonlyArray<T>)[]): T[]; concat(...items: (T | T[] | ReadonlyArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>p2 : T[]
|
||||
|
||||
var o3 = { ...t }; // Error, generic type paramter
|
||||
|
||||
@@ -348,9 +348,9 @@ class ListWrapper {
|
||||
>a : any[]
|
||||
>b : any[]
|
||||
>a.concat(b) : any[]
|
||||
>a.concat : { (...items: ReadonlyArray<any>[]): any[]; (...items: any[]): any[]; }
|
||||
>a.concat : { (...items: (any[] | ReadonlyArray<any>)[]): any[]; (...items: any[]): any[]; }
|
||||
>a : any[]
|
||||
>concat : { (...items: ReadonlyArray<any>[]): any[]; (...items: any[]): any[]; }
|
||||
>concat : { (...items: (any[] | ReadonlyArray<any>)[]): any[]; (...items: any[]): any[]; }
|
||||
>b : any[]
|
||||
|
||||
static insert<T>(dit: typeof ListWrapper, list: T[], index: number, value: T) { list.splice(index, 0, value); }
|
||||
|
||||
@@ -124,9 +124,9 @@ var flat = _.reduceRight(list, (a, b) => a.concat(b), []);
|
||||
>a : number[]
|
||||
>b : number[]
|
||||
>a.concat(b) : number[]
|
||||
>a.concat : { (...items: ReadonlyArray<number>[]): number[]; (...items: (number | ReadonlyArray<number>)[]): number[]; }
|
||||
>a.concat : { (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }
|
||||
>a : number[]
|
||||
>concat : { (...items: ReadonlyArray<number>[]): number[]; (...items: (number | ReadonlyArray<number>)[]): number[]; }
|
||||
>concat : { (...items: (number[] | ReadonlyArray<number>)[]): number[]; (...items: (number | number[] | ReadonlyArray<number>)[]): number[]; }
|
||||
>b : number[]
|
||||
>[] : undefined[]
|
||||
|
||||
|
||||
5
tests/cases/compiler/arrayConcat3.ts
Normal file
5
tests/cases/compiler/arrayConcat3.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// 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);
|
||||
}
|
||||
Reference in New Issue
Block a user