diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 24e2c489197c3..c28d21414218e 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1138,7 +1138,7 @@ interface ReadonlyArray { * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[]; + map(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): { -readonly [P in keyof this]: U } extends U[] ? { -readonly [P in keyof this]: U } : U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. @@ -1308,7 +1308,7 @@ interface Array { * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): { -readonly [P in keyof this]: U } extends U[] ? { -readonly [P in keyof this]: U } : U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt index 31caaef42283b..aa1451185ef82 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt +++ b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,12): error TS2493: Tuple type '[string, number]' of length '2' has no element at index '2'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(16,5): error TS2461: Type 'StrNum' is not an array type. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(17,5): error TS2461: Type '{ 0: string; 1: number; length: 2; }' is not an array type. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(18,5): error TS2741: Property '2' is missing in type '[string, number]' but required in type '[number, number, number]'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(19,5): error TS2741: Property '2' is missing in type 'StrNum' but required in type '[number, number, number]'. @@ -28,7 +29,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(31,5): error tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, string]'. -==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (17 errors) ==== +==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (18 errors) ==== interface StrNum extends Array { 0: string; 1: number; @@ -47,6 +48,8 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error ~ !!! error TS2493: Tuple type '[string, number]' of length '2' has no element at index '2'. var [d, e, f] = y; + ~~~~~~~~~ +!!! error TS2461: Type 'StrNum' is not an array type. var [g, h, i] = z; ~~~~~~~~~ !!! error TS2461: Type '{ 0: string; 1: number; length: 2; }' is not an array type. diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.types b/tests/baselines/reference/arityAndOrderCompatibility01.types index aa658ba762934..44debb57aceeb 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.types +++ b/tests/baselines/reference/arityAndOrderCompatibility01.types @@ -36,9 +36,9 @@ var [a, b, c] = x; >x : [string, number] var [d, e, f] = y; ->d : string ->e : number ->f : string | number +>d : any +>e : any +>f : any >y : StrNum var [g, h, i] = z; diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt index 66b3c2c869106..f9b49f79389c1 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt @@ -1,12 +1,29 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'readonly B[]'. Property 'b' is missing in type 'A' but required in type 'B'. +tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(15,1): error TS2322: Type 'C' is not assignable to type 'readonly A[]'. + The types returned by 'map(...)' are incompatible between these types. + Type '{ [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]' is not assignable to type 'U[]'. + Type 'U[] | { [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; }' is not assignable to type 'U[]'. + Type '{ [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; }' is not assignable to type 'U[]'. + Types of property 'length' are incompatible. + Type 'U' is not assignable to type 'number'. +tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(16,1): error TS2322: Type 'C' is not assignable to type 'readonly A[]'. + The types returned by 'map(...)' are incompatible between these types. + Type '{ [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]' is not assignable to type 'U[]'. + Type 'U[] | { [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; }' is not assignable to type 'U[]'. + Type '{ [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; }' is not assignable to type 'U[]'. + Types of property 'length' are incompatible. + Type 'U' is not assignable to type 'number'. +tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(17,1): error TS2322: Type 'C' is not assignable to type 'readonly B[]'. + The types returned by 'map(...)' are incompatible between these types. + Type '{ [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]' is not assignable to type 'U[]'. tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C' is not assignable to type 'readonly B[]'. The types returned by 'concat(...)' are incompatible between these types. Type 'A[]' is not assignable to type 'B[]'. Type 'A' is not assignable to type 'B'. -==== tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts (2 errors) ==== +==== tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts (5 errors) ==== class A { a } class B extends A { b } class C extends Array { c } @@ -26,8 +43,28 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T !!! related TS2728 tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts:2:21: 'b' is declared here. rra = cra; + ~~~ +!!! error TS2322: Type 'C' is not assignable to type 'readonly A[]'. +!!! error TS2322: The types returned by 'map(...)' are incompatible between these types. +!!! error TS2322: Type '{ [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]' is not assignable to type 'U[]'. +!!! error TS2322: Type 'U[] | { [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; }' is not assignable to type 'U[]'. +!!! error TS2322: Type '{ [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; }' is not assignable to type 'U[]'. +!!! error TS2322: Types of property 'length' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'number'. rra = crb; // OK, C is assignable to ReadonlyArray + ~~~ +!!! error TS2322: Type 'C' is not assignable to type 'readonly A[]'. +!!! error TS2322: The types returned by 'map(...)' are incompatible between these types. +!!! error TS2322: Type '{ [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]' is not assignable to type 'U[]'. +!!! error TS2322: Type 'U[] | { [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; }' is not assignable to type 'U[]'. +!!! error TS2322: Type '{ [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; }' is not assignable to type 'U[]'. +!!! error TS2322: Types of property 'length' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'number'. rrb = crb; + ~~~ +!!! error TS2322: Type 'C' is not assignable to type 'readonly B[]'. +!!! error TS2322: The types returned by 'map(...)' are incompatible between these types. +!!! error TS2322: Type '{ [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; c: U; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]' is not assignable to type 'U[]'. rrb = cra; // error: 'A' is not assignable to 'B' ~~~ !!! error TS2322: Type 'C' is not assignable to type 'readonly B[]'. diff --git a/tests/baselines/reference/bestChoiceType.errors.txt b/tests/baselines/reference/bestChoiceType.errors.txt new file mode 100644 index 0000000000000..dd27c2cdfaeef --- /dev/null +++ b/tests/baselines/reference/bestChoiceType.errors.txt @@ -0,0 +1,36 @@ +tests/cases/compiler/bestChoiceType.ts(3,23): error TS2349: This expression is not callable. + Each member of the union type '((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])' has signatures, but none of those signatures are compatible with each other. +tests/cases/compiler/bestChoiceType.ts(10,15): error TS2349: This expression is not callable. + Each member of the union type '((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])' has signatures, but none of those signatures are compatible with each other. +tests/cases/compiler/bestChoiceType.ts(16,15): error TS2349: This expression is not callable. + Each member of the union type '((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])' has signatures, but none of those signatures are compatible with each other. + + +==== tests/cases/compiler/bestChoiceType.ts (3 errors) ==== + // Repro from #10041 + + (''.match(/ /) || []).map(s => s.toLowerCase()); + ~~~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Each member of the union type '((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])' has signatures, but none of those signatures are compatible with each other. + + // Similar cases + + function f1() { + let x = ''.match(/ /); + let y = x || []; + let z = y.map(s => s.toLowerCase()); + ~~~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Each member of the union type '((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])' has signatures, but none of those signatures are compatible with each other. + } + + function f2() { + let x = ''.match(/ /); + let y = x ? x : []; + let z = y.map(s => s.toLowerCase()); + ~~~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Each member of the union type '((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])' has signatures, but none of those signatures are compatible with each other. + } + \ No newline at end of file diff --git a/tests/baselines/reference/bestChoiceType.symbols b/tests/baselines/reference/bestChoiceType.symbols index c7732890347d0..0072356223368 100644 --- a/tests/baselines/reference/bestChoiceType.symbols +++ b/tests/baselines/reference/bestChoiceType.symbols @@ -2,14 +2,12 @@ // Repro from #10041 (''.match(/ /) || []).map(s => s.toLowerCase()); ->(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >''.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) >match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 2, 26)) ->s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 2, 26)) ->toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) // Similar cases @@ -27,13 +25,11 @@ function f1() { let z = y.map(s => s.toLowerCase()); >z : Symbol(z, Decl(bestChoiceType.ts, 9, 7)) ->y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >y : Symbol(y, Decl(bestChoiceType.ts, 8, 7)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 9, 18)) ->s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 9, 18)) ->toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) } function f2() { @@ -51,12 +47,10 @@ function f2() { let z = y.map(s => s.toLowerCase()); >z : Symbol(z, Decl(bestChoiceType.ts, 15, 7)) ->y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >y : Symbol(y, Decl(bestChoiceType.ts, 14, 7)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 15, 18)) ->s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 15, 18)) ->toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) } diff --git a/tests/baselines/reference/bestChoiceType.types b/tests/baselines/reference/bestChoiceType.types index 49997d1e273cc..771697a2e45e6 100644 --- a/tests/baselines/reference/bestChoiceType.types +++ b/tests/baselines/reference/bestChoiceType.types @@ -2,23 +2,23 @@ // Repro from #10041 (''.match(/ /) || []).map(s => s.toLowerCase()); ->(''.match(/ /) || []).map(s => s.toLowerCase()) : string[] ->(''.match(/ /) || []).map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] ->(''.match(/ /) || []) : RegExpMatchArray ->''.match(/ /) || [] : RegExpMatchArray +>(''.match(/ /) || []).map(s => s.toLowerCase()) : any +>(''.match(/ /) || []).map : ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[]) +>(''.match(/ /) || []) : RegExpMatchArray | never[] +>''.match(/ /) || [] : RegExpMatchArray | never[] >''.match(/ /) : RegExpMatchArray | null >''.match : (regexp: string | RegExp) => RegExpMatchArray | null >'' : "" >match : (regexp: string | RegExp) => RegExpMatchArray | null >/ / : RegExp >[] : never[] ->map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] ->s => s.toLowerCase() : (s: string) => string ->s : string ->s.toLowerCase() : string ->s.toLowerCase : () => string ->s : string ->toLowerCase : () => string +>map : ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[]) +>s => s.toLowerCase() : (s: any) => any +>s : any +>s.toLowerCase() : any +>s.toLowerCase : any +>s : any +>toLowerCase : any // Similar cases @@ -34,23 +34,23 @@ function f1() { >/ / : RegExp let y = x || []; ->y : RegExpMatchArray ->x || [] : RegExpMatchArray +>y : RegExpMatchArray | never[] +>x || [] : RegExpMatchArray | never[] >x : RegExpMatchArray | null >[] : never[] let z = y.map(s => s.toLowerCase()); ->z : string[] ->y.map(s => s.toLowerCase()) : string[] ->y.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] ->y : RegExpMatchArray ->map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] ->s => s.toLowerCase() : (s: string) => string ->s : string ->s.toLowerCase() : string ->s.toLowerCase : () => string ->s : string ->toLowerCase : () => string +>z : any +>y.map(s => s.toLowerCase()) : any +>y.map : ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[]) +>y : RegExpMatchArray | never[] +>map : ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[]) +>s => s.toLowerCase() : (s: any) => any +>s : any +>s.toLowerCase() : any +>s.toLowerCase : any +>s : any +>toLowerCase : any } function f2() { @@ -65,23 +65,23 @@ function f2() { >/ / : RegExp let y = x ? x : []; ->y : RegExpMatchArray ->x ? x : [] : RegExpMatchArray +>y : RegExpMatchArray | never[] +>x ? x : [] : RegExpMatchArray | never[] >x : RegExpMatchArray | null >x : RegExpMatchArray >[] : never[] let z = y.map(s => s.toLowerCase()); ->z : string[] ->y.map(s => s.toLowerCase()) : string[] ->y.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] ->y : RegExpMatchArray ->map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] ->s => s.toLowerCase() : (s: string) => string ->s : string ->s.toLowerCase() : string ->s.toLowerCase : () => string ->s : string ->toLowerCase : () => string +>z : any +>y.map(s => s.toLowerCase()) : any +>y.map : ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[]) +>y : RegExpMatchArray | never[] +>map : ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } extends U[] ? { [x: number]: U; index?: U | undefined; input?: U | undefined; length: U; toString: U; toLocaleString: U; pop: U; push: U; concat: U; join: U; reverse: U; shift: U; slice: U; sort: U; splice: U; unshift: U; indexOf: U; lastIndexOf: U; every: U; some: U; forEach: U; map: U; filter: U; reduce: U; reduceRight: U; } : U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[]) +>s => s.toLowerCase() : (s: any) => any +>s : any +>s.toLowerCase() : any +>s.toLowerCase : any +>s : any +>toLowerCase : any } diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index 4e6f9f71c923e..9c9579ef14285 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -151,18 +151,18 @@ >0 : 0 ((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); ->((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10) : boolean[] ->((first, ...rest) => first ? [] : rest.map(n => n > 0)) : (first: number, rest_0: number, rest_1: number) => boolean[] ->(first, ...rest) => first ? [] : rest.map(n => n > 0) : (first: number, rest_0: number, rest_1: number) => boolean[] +>((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10) : any[] | [boolean, boolean] +>((first, ...rest) => first ? [] : rest.map(n => n > 0)) : (first: number, rest_0: number, rest_1: number) => any[] | [boolean, boolean] +>(first, ...rest) => first ? [] : rest.map(n => n > 0) : (first: number, rest_0: number, rest_1: number) => any[] | [boolean, boolean] >first : number >rest : [number, number] ->first ? [] : rest.map(n => n > 0) : boolean[] +>first ? [] : rest.map(n => n > 0) : undefined[] | [boolean, boolean] >first : number >[] : undefined[] ->rest.map(n => n > 0) : boolean[] ->rest.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>rest.map(n => n > 0) : [boolean, boolean] +>rest.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U] >rest : [number, number] ->map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U] >n => n > 0 : (n: number) => boolean >n : number >n > 0 : boolean diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.types b/tests/baselines/reference/contextuallyTypedIifeStrict.types index 18ad0a1241f73..a81d425e49823 100644 --- a/tests/baselines/reference/contextuallyTypedIifeStrict.types +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.types @@ -151,18 +151,18 @@ >0 : 0 ((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); ->((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10) : boolean[] ->((first, ...rest) => first ? [] : rest.map(n => n > 0)) : (first: number, rest_0: number, rest_1: number) => boolean[] ->(first, ...rest) => first ? [] : rest.map(n => n > 0) : (first: number, rest_0: number, rest_1: number) => boolean[] +>((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10) : never[] | [boolean, boolean] +>((first, ...rest) => first ? [] : rest.map(n => n > 0)) : (first: number, rest_0: number, rest_1: number) => never[] | [boolean, boolean] +>(first, ...rest) => first ? [] : rest.map(n => n > 0) : (first: number, rest_0: number, rest_1: number) => never[] | [boolean, boolean] >first : number >rest : [number, number] ->first ? [] : rest.map(n => n > 0) : boolean[] +>first ? [] : rest.map(n => n > 0) : never[] | [boolean, boolean] >first : number >[] : never[] ->rest.map(n => n > 0) : boolean[] ->rest.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>rest.map(n => n > 0) : [boolean, boolean] +>rest.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U] >rest : [number, number] ->map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U] >n => n > 0 : (n: number) => boolean >n : number >n > 0 : boolean diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index dd01ac9651928..85a07b28e3de1 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -4,12 +4,13 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2493: Tuple type '[]' of length '0' has no element at index '1'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,51): error TS2322: Type 'number' is not assignable to type 'boolean'. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(17,5): error TS2461: Type 'J' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2739: Type 'number[]' is missing the following properties from type '[number, number]': 0, 1 tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2739: Type 'number[]' is missing the following properties from type '[string, string]': 0, 1 tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(34,5): error TS2461: Type 'F' is not an array type. -==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (9 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (10 errors) ==== // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is the type Any, or var [[a0], [[a1]]] = [] // Error @@ -39,6 +40,8 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss return <[number, number, number]>[1, 2, 3]; } var [b3 = "string", b4, b5] = bar(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2461: Type 'J' is not an array type. // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.types index 86723735bb544..411a423f53274 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.types @@ -39,10 +39,10 @@ function bar(): J { >3 : 3 } var [b3 = "string", b4, b5] = bar(); // Error ->b3 : string | Number +>b3 : any >"string" : "string" ->b4 : Number ->b5 : number +>b4 : any +>b5 : any >bar() : J >bar : () => J diff --git a/tests/baselines/reference/genericRestParameters3.errors.txt b/tests/baselines/reference/genericRestParameters3.errors.txt index 9e3e9d97de42d..d83197e8c394a 100644 --- a/tests/baselines/reference/genericRestParameters3.errors.txt +++ b/tests/baselines/reference/genericRestParameters3.errors.txt @@ -22,6 +22,7 @@ tests/cases/conformance/types/rest/genericRestParameters3.ts(37,21): error TS234 Property '0' is missing in type 'CoolArray' but required in type '[(...args: any[]) => void]'. tests/cases/conformance/types/rest/genericRestParameters3.ts(44,32): error TS2345: Argument of type '[10, 20]' is not assignable to parameter of type 'CoolArray'. Property 'hello' is missing in type '[10, 20]' but required in type 'CoolArray'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(46,25): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/rest/genericRestParameters3.ts(49,1): error TS2345: Argument of type '[]' is not assignable to parameter of type 'CoolArray'. Property 'hello' is missing in type '[]' but required in type 'CoolArray'. tests/cases/conformance/types/rest/genericRestParameters3.ts(50,5): error TS2345: Argument of type '[number]' is not assignable to parameter of type 'CoolArray'. @@ -30,11 +31,12 @@ tests/cases/conformance/types/rest/genericRestParameters3.ts(51,5): error TS2345 Property 'hello' is missing in type '[number, number]' but required in type 'CoolArray'. tests/cases/conformance/types/rest/genericRestParameters3.ts(52,5): error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'CoolArray'. Property 'hello' is missing in type 'number[]' but required in type 'CoolArray'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(52,8): error TS2461: Type 'CoolArray' is not an array type. tests/cases/conformance/types/rest/genericRestParameters3.ts(59,5): error TS2345: Argument of type '["what"]' is not assignable to parameter of type '[] | [number, string]'. Property '1' is missing in type '["what"]' but required in type '[number, string]'. -==== tests/cases/conformance/types/rest/genericRestParameters3.ts (15 errors) ==== +==== tests/cases/conformance/types/rest/genericRestParameters3.ts (17 errors) ==== declare let f1: (x: string, ...args: [string] | [number, boolean]) => void; declare let f2: (x: string, y: string) => void; declare let f3: (x: string, y: number, z: boolean) => void; @@ -117,6 +119,8 @@ tests/cases/conformance/types/rest/genericRestParameters3.ts(59,5): error TS2345 !!! related TS2728 tests/cases/conformance/types/rest/genericRestParameters3.ts:30:5: 'hello' is declared here. declare function baz(...args: CoolArray): void; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. declare const ca: CoolArray; baz(); // Error @@ -139,6 +143,8 @@ tests/cases/conformance/types/rest/genericRestParameters3.ts(59,5): error TS2345 !!! error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'CoolArray'. !!! error TS2345: Property 'hello' is missing in type 'number[]' but required in type 'CoolArray'. !!! related TS2728 tests/cases/conformance/types/rest/genericRestParameters3.ts:30:5: 'hello' is declared here. + ~~ +!!! error TS2461: Type 'CoolArray' is not an array type. // Repro from #26491 diff --git a/tests/baselines/reference/genericRestParameters3.types b/tests/baselines/reference/genericRestParameters3.types index a0d90a308d7b4..c73abe74c531f 100644 --- a/tests/baselines/reference/genericRestParameters3.types +++ b/tests/baselines/reference/genericRestParameters3.types @@ -186,7 +186,7 @@ baz(1, 2); // Error baz(...ca); // Error >baz(...ca) : any >baz : (...args: CoolArray) => void ->...ca : number +>...ca : any >ca : CoolArray // Repro from #26491 diff --git a/tests/baselines/reference/implementArrayInterface.errors.txt b/tests/baselines/reference/implementArrayInterface.errors.txt new file mode 100644 index 0000000000000..773bb39d61305 --- /dev/null +++ b/tests/baselines/reference/implementArrayInterface.errors.txt @@ -0,0 +1,43 @@ +tests/cases/compiler/implementArrayInterface.ts(22,5): error TS2416: Property 'map' in type 'MyArray' is not assignable to the same property in base type 'T[]'. + Type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => { -readonly [P in keyof this]: U; } extends U[] ? { -readonly [P in keyof this]: U; } : U[]'. + Type 'U[]' is not assignable to type '{ -readonly [P in keyof this]: U; } extends U[] ? { -readonly [P in keyof this]: U; } : U[]'. + + +==== tests/cases/compiler/implementArrayInterface.ts (1 errors) ==== + declare class MyArray implements Array { + toString(): string; + toLocaleString(): string; + concat(...items: U[]): T[]; + concat(...items: T[]): T[]; + join(separator?: string): string; + pop(): T; + push(...items: T[]): number; + reverse(): T[]; + shift(): T; + slice(start?: number, end?: number): T[]; + sort(compareFn?: (a: T, b: T) => number): this; + splice(start: 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(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + ~~~ +!!! error TS2416: Property 'map' in type 'MyArray' is not assignable to the same property in base type 'T[]'. +!!! error TS2416: Type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => { -readonly [P in keyof this]: U; } extends U[] ? { -readonly [P in keyof this]: U; } : U[]'. +!!! error TS2416: Type 'U[]' is not assignable to type '{ -readonly [P in keyof this]: U; } extends U[] ? { -readonly [P in keyof this]: U; } : U[]'. + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + length: number; + + [n: number]: T; + } + \ No newline at end of file diff --git a/tests/baselines/reference/initializedDestructuringAssignmentTypes.errors.txt b/tests/baselines/reference/initializedDestructuringAssignmentTypes.errors.txt index 9a8cb12b45b61..f490cbc1432d8 100644 --- a/tests/baselines/reference/initializedDestructuringAssignmentTypes.errors.txt +++ b/tests/baselines/reference/initializedDestructuringAssignmentTypes.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/initializedDestructuringAssignmentTypes.ts(3,3): error TS2339: Property 'toFixed' does not exist on type 'string'. +tests/cases/compiler/initializedDestructuringAssignmentTypes.ts(1,7): error TS2461: Type 'RegExpMatchArray | undefined[]' is not an array type. ==== tests/cases/compiler/initializedDestructuringAssignmentTypes.ts (1 errors) ==== const [, a = ''] = ''.match('') || []; + ~~~~~~~~~~ +!!! error TS2461: Type 'RegExpMatchArray | undefined[]' is not an array type. - a.toFixed() - ~~~~~~~ -!!! error TS2339: Property 'toFixed' does not exist on type 'string'. \ No newline at end of file + a.toFixed() \ No newline at end of file diff --git a/tests/baselines/reference/initializedDestructuringAssignmentTypes.types b/tests/baselines/reference/initializedDestructuringAssignmentTypes.types index 333fc5d92ccd8..0b7dde7c11400 100644 --- a/tests/baselines/reference/initializedDestructuringAssignmentTypes.types +++ b/tests/baselines/reference/initializedDestructuringAssignmentTypes.types @@ -1,9 +1,9 @@ === tests/cases/compiler/initializedDestructuringAssignmentTypes.ts === const [, a = ''] = ''.match('') || []; > : undefined ->a : string +>a : any >'' : "" ->''.match('') || [] : RegExpMatchArray +>''.match('') || [] : RegExpMatchArray | undefined[] >''.match('') : RegExpMatchArray >''.match : (regexp: string | RegExp) => RegExpMatchArray >'' : "" @@ -14,6 +14,6 @@ const [, a = ''] = ''.match('') || []; a.toFixed() >a.toFixed() : any >a.toFixed : any ->a : string +>a : any >toFixed : any diff --git a/tests/baselines/reference/mapOnTupleTypes01.js b/tests/baselines/reference/mapOnTupleTypes01.js index 3298190fdee57..d1d5f8cc1a5f4 100644 --- a/tests/baselines/reference/mapOnTupleTypes01.js +++ b/tests/baselines/reference/mapOnTupleTypes01.js @@ -71,11 +71,11 @@ exports.h = numNumNumNumNum.map(function (n) { return n * n; }); //// [mapOnTupleTypes01.d.ts] export declare let mapOnLooseArrayLiteral: number[]; -export declare let a: number[]; -export declare let b: number[]; -export declare let c: number[]; -export declare let d: (string | number)[]; -export declare let e: number[]; -export declare let f: number[]; -export declare let g: number[]; -export declare let h: number[]; +export declare let a: [number]; +export declare let b: [number, number]; +export declare let c: [number, number]; +export declare let d: [string | number, string | number]; +export declare let e: [number, number, number]; +export declare let f: [number, number, number, number]; +export declare let g: [number, number, number, number, number]; +export declare let h: [number, number, number, number, number]; diff --git a/tests/baselines/reference/mapOnTupleTypes01.types b/tests/baselines/reference/mapOnTupleTypes01.types index adb8a2e191c26..4c9dc122d7e26 100644 --- a/tests/baselines/reference/mapOnTupleTypes01.types +++ b/tests/baselines/reference/mapOnTupleTypes01.types @@ -23,11 +23,11 @@ let numTuple: [number] = [1]; >1 : 1 export let a = numTuple.map(x => x * x); ->a : number[] ->numTuple.map(x => x * x) : number[] ->numTuple.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>a : [number] +>numTuple.map(x => x * x) : [number] +>numTuple.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U] >numTuple : [number] ->map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U] >x => x * x : (x: number) => number >x : number >x * x : number @@ -55,11 +55,11 @@ let numStr: [number, string] = [ 100, "hello"]; >"hello" : "hello" export let b = numNum.map(n => n * n); ->b : number[] ->numNum.map(n => n * n) : number[] ->numNum.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>b : [number, number] +>numNum.map(n => n * n) : [number, number] +>numNum.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U] >numNum : [number, number] ->map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U] >n => n * n : (n: number) => number >n : number >n * n : number @@ -67,11 +67,11 @@ export let b = numNum.map(n => n * n); >n : number export let c = strStr.map(s => s.charCodeAt(0)); ->c : number[] ->strStr.map(s => s.charCodeAt(0)) : number[] ->strStr.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +>c : [number, number] +>strStr.map(s => s.charCodeAt(0)) : [number, number] +>strStr.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => [U, U] >strStr : [string, string] ->map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => [U, U] >s => s.charCodeAt(0) : (s: string) => number >s : string >s.charCodeAt(0) : number @@ -81,11 +81,11 @@ export let c = strStr.map(s => s.charCodeAt(0)); >0 : 0 export let d = numStr.map(x => x); ->d : (string | number)[] ->numStr.map(x => x) : (string | number)[] ->numStr.map : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any) => U[] +>d : [string | number, string | number] +>numStr.map(x => x) : [string | number, string | number] +>numStr.map : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any) => [U, U] >numStr : [number, string] ->map : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any) => [U, U] >x => x : (x: string | number) => string | number >x : string | number >x : string | number @@ -100,11 +100,11 @@ let numNumNum: [number, number, number] = [1, 2, 3]; >3 : 3 export let e = numNumNum.map(n => n * n); ->e : number[] ->numNumNum.map(n => n * n) : number[] ->numNumNum.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>e : [number, number, number] +>numNumNum.map(n => n * n) : [number, number, number] +>numNumNum.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U, U] >numNumNum : [number, number, number] ->map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U, U] >n => n * n : (n: number) => number >n : number >n * n : number @@ -122,11 +122,11 @@ let numNumNumNum: [number, number, number, number] = [1, 2, 3, 4]; >4 : 4 export let f = numNumNumNum.map(n => n * n); ->f : number[] ->numNumNumNum.map(n => n * n) : number[] ->numNumNumNum.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>f : [number, number, number, number] +>numNumNumNum.map(n => n * n) : [number, number, number, number] +>numNumNumNum.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U, U, U] >numNumNumNum : [number, number, number, number] ->map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U, U, U] >n => n * n : (n: number) => number >n : number >n * n : number @@ -145,11 +145,11 @@ let numNumNumNumNum: [number, number, number, number, number] = [1, 2, 3, 4, 5]; >5 : 5 export let g = numNumNumNumNum.map(n => n * n); ->g : number[] ->numNumNumNumNum.map(n => n * n) : number[] ->numNumNumNumNum.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>g : [number, number, number, number, number] +>numNumNumNumNum.map(n => n * n) : [number, number, number, number, number] +>numNumNumNumNum.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U, U, U, U] >numNumNumNumNum : [number, number, number, number, number] ->map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U, U, U, U] >n => n * n : (n: number) => number >n : number >n * n : number @@ -170,11 +170,11 @@ let numNumNumNumNumNum: [number, number, number, number, number, number] = [1, 2 >6 : 6 export let h = numNumNumNumNum.map(n => n * n); ->h : number[] ->numNumNumNumNum.map(n => n * n) : number[] ->numNumNumNumNum.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>h : [number, number, number, number, number] +>numNumNumNumNum.map(n => n * n) : [number, number, number, number, number] +>numNumNumNumNum.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U, U, U, U] >numNumNumNumNum : [number, number, number, number, number] ->map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U, U, U, U] >n => n * n : (n: number) => number >n : number >n * n : number diff --git a/tests/baselines/reference/mapOnTupleTypes02.js b/tests/baselines/reference/mapOnTupleTypes02.js index 8e0a8720a18cc..2fd4daab16bf5 100644 --- a/tests/baselines/reference/mapOnTupleTypes02.js +++ b/tests/baselines/reference/mapOnTupleTypes02.js @@ -16,4 +16,4 @@ exports.increment = increment; //// [mapOnTupleTypes02.d.ts] export declare type Point = [number, number]; -export declare function increment(point: Point): number[]; +export declare function increment(point: Point): [number, number]; diff --git a/tests/baselines/reference/mapOnTupleTypes02.types b/tests/baselines/reference/mapOnTupleTypes02.types index 3f443a735cbe3..d503f7c2825af 100644 --- a/tests/baselines/reference/mapOnTupleTypes02.types +++ b/tests/baselines/reference/mapOnTupleTypes02.types @@ -3,14 +3,14 @@ export type Point = [number, number]; >Point : Point export function increment(point: Point) { ->increment : (point: Point) => number[] +>increment : (point: Point) => [number, number] >point : Point return point.map(d => d + 1); ->point.map(d => d + 1) : number[] ->point.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>point.map(d => d + 1) : [number, number] +>point.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U] >point : Point ->map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => [U, U] >d => d + 1 : (d: number) => number >d : number >d + 1 : number diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.types b/tests/baselines/reference/restParameterWithBindingPattern3.types index b98f0cdd367d7..530b5806994d1 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.types +++ b/tests/baselines/reference/restParameterWithBindingPattern3.types @@ -31,5 +31,5 @@ function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) >b : string >true : true >rest : any ->rest : { [n: number]: string | number | boolean; 0: boolean; 1: string; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): string | number | boolean; push(...items: (string | number | boolean)[]): number; concat(...items: ConcatArray[]): (string | number | boolean)[]; concat(...items: (string | number | boolean | ConcatArray)[]): (string | number | boolean)[]; join(separator?: string): string; reverse(): (string | number | boolean)[]; shift(): string | number | boolean; slice(start?: number, end?: number): (string | number | boolean)[]; sort(compareFn?: (a: string | number | boolean, b: string | number | boolean) => number): [boolean, string, number]; splice(start: number, deleteCount?: number): (string | number | boolean)[]; splice(start: number, deleteCount: number, ...items: (string | number | boolean)[]): (string | number | boolean)[]; unshift(...items: (string | number | boolean)[]): number; indexOf(searchElement: string | number | boolean, fromIndex?: number): number; lastIndexOf(searchElement: string | number | boolean, fromIndex?: number): number; every(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => void, thisArg?: any): void; map(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): (string | number | boolean)[]; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; } +>rest : { [n: number]: string | number | boolean; 0: boolean; 1: string; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): string | number | boolean; push(...items: (string | number | boolean)[]): number; concat(...items: ConcatArray[]): (string | number | boolean)[]; concat(...items: (string | number | boolean | ConcatArray)[]): (string | number | boolean)[]; join(separator?: string): string; reverse(): (string | number | boolean)[]; shift(): string | number | boolean; slice(start?: number, end?: number): (string | number | boolean)[]; sort(compareFn?: (a: string | number | boolean, b: string | number | boolean) => number): [boolean, string, number]; splice(start: number, deleteCount?: number): (string | number | boolean)[]; splice(start: number, deleteCount: number, ...items: (string | number | boolean)[]): (string | number | boolean)[]; unshift(...items: (string | number | boolean)[]): number; indexOf(searchElement: string | number | boolean, fromIndex?: number): number; lastIndexOf(searchElement: string | number | boolean, fromIndex?: number): number; every(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => void, thisArg?: any): void; map(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => U, thisArg?: any): [U, U, U]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): (string | number | boolean)[]; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; } diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt b/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt index 5c31031cba4bc..654f053e8bb62 100644 --- a/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt +++ b/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt @@ -1,12 +1,40 @@ +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(7,14): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(8,22): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,11): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,11): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,26): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(12,9): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(16,6): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(17,9): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(17,9): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(17,24): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(21,6): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(22,9): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(26,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(27,21): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(27,21): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(27,36): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(28,9): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(34,15): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(35,23): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,11): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,11): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,35): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(39,9): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(43,6): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(44,9): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(44,9): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(44,33): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(48,6): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(49,9): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(53,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(54,21): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(54,21): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(54,45): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(55,9): error TS2370: A rest parameter must be of an array type. -==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts (6 errors) ==== +==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts (34 errors) ==== // Rest parameters must be an array type if they have a type annotation, // user defined subtypes of array do not count, all of these are errors @@ -14,64 +42,120 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfN interface MyThing2 extends Array { } function foo(...x: MyThing) { } + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. var f = function foo(...x: MyThing) { } + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. var f2 = (...x: MyThing, ...y: MyThing) => { } ~~~ !!! error TS1014: A rest parameter must be last in a parameter list. + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. class C { foo(...x: MyThing) { } + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. } interface I { (...x: MyThing); + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. foo(...x: MyThing, ...y: MyThing); ~~~ !!! error TS1014: A rest parameter must be last in a parameter list. + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. } var a: { (...x: MyThing); + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. foo(...x: MyThing); + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. } var b = { foo(...x: MyThing) { }, + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. a: function foo(...x: MyThing, ...y: MyThing) { }, ~~~ !!! error TS1014: A rest parameter must be last in a parameter list. + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. b: (...x: MyThing) => { } + ~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. } function foo2(...x: MyThing2) { } + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. var f3 = function foo(...x: MyThing2) { } + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. var f4 = (...x: MyThing2, ...y: MyThing2) => { } ~~~ !!! error TS1014: A rest parameter must be last in a parameter list. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. class C2 { foo(...x: MyThing2) { } + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. } interface I2 { (...x: MyThing2); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. foo(...x: MyThing2, ...y: MyThing2); ~~~ !!! error TS1014: A rest parameter must be last in a parameter list. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. } var a2: { (...x: MyThing2); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. foo(...x: MyThing2); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. } var b2 = { foo(...x: MyThing2) { }, + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. a: function foo(...x: MyThing2, ...y: MyThing2) { }, ~~~ !!! error TS1014: A rest parameter must be last in a parameter list. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. b: (...x: MyThing2) => { } + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. } \ No newline at end of file