|
| 1 | +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(40,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 2 | + Type 'string' is not assignable to type 'number'. |
| 3 | +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(41,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 4 | + Type 'string' is not assignable to type 'number'. |
| 5 | +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(42,13): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 6 | + Type 'string' is not assignable to type 'number'. |
| 7 | +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(43,13): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 8 | + Type 'string' is not assignable to type 'number'. |
| 9 | +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(44,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 10 | + Type 'string' is not assignable to type 'number'. |
| 11 | +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(45,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 12 | + Type 'string' is not assignable to type 'number'. |
| 13 | +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(46,1): error TS2346: Supplied parameters do not match any signature of call target. |
| 14 | +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(46,11): error TS2461: Type '(a?: number, b?: number) => void' is not an array type. |
| 15 | +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(47,1): error TS2346: Supplied parameters do not match any signature of call target. |
| 16 | +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(48,1): error TS2346: Supplied parameters do not match any signature of call target. |
| 17 | + |
| 18 | + |
| 19 | +==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (10 errors) ==== |
| 20 | + // Desired semantics: take type of array that is spread, |
| 21 | + // allow it to be applied to a |
| 22 | + // *trailing* set of optional parameters whose types match. |
| 23 | + // Length is *not* checked, the parameters it's applied to just have to be optional. |
| 24 | + |
| 25 | + // that means that tuples are non-starters because their array element type |
| 26 | + // is a union like string | number. |
| 27 | + |
| 28 | + // with exceptions for JS functions that use arguments, or maybe all JS functions |
| 29 | + |
| 30 | + declare function all(a?: number, b?: number): void; |
| 31 | + declare function weird(a?: number | string, b?: number | string): void; |
| 32 | + declare function prefix(s: string, a?: number, b?: number): void; |
| 33 | + declare function rest(s: string, a?: number, b?: number, ...rest: number[]): void; |
| 34 | + declare function normal(s: string): void; |
| 35 | + declare function thunk(): string; |
| 36 | + |
| 37 | + declare var ns: number[]; |
| 38 | + declare var mixed: (number | string)[]; |
| 39 | + declare var tuple: [number, string]; |
| 40 | + |
| 41 | + // good |
| 42 | + all(...ns) |
| 43 | + weird(...ns) |
| 44 | + weird(...mixed) |
| 45 | + weird(...tuple) |
| 46 | + prefix("a", ...ns) |
| 47 | + rest("d", ...ns) |
| 48 | + |
| 49 | + |
| 50 | + // this covers the arguments case |
| 51 | + normal("g", ...ns) |
| 52 | + normal("h", ...mixed) |
| 53 | + normal("i", ...tuple) |
| 54 | + thunk(...ns) |
| 55 | + thunk(...mixed) |
| 56 | + thunk(...tuple) |
| 57 | + |
| 58 | + // bad |
| 59 | + all(...mixed) |
| 60 | + ~~~~~~~~ |
| 61 | +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 62 | +!!! error TS2345: Type 'string' is not assignable to type 'number'. |
| 63 | + all(...tuple) |
| 64 | + ~~~~~~~~ |
| 65 | +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 66 | +!!! error TS2345: Type 'string' is not assignable to type 'number'. |
| 67 | + prefix("b", ...mixed) |
| 68 | + ~~~~~~~~ |
| 69 | +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 70 | +!!! error TS2345: Type 'string' is not assignable to type 'number'. |
| 71 | + prefix("c", ...tuple) |
| 72 | + ~~~~~~~~ |
| 73 | +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 74 | +!!! error TS2345: Type 'string' is not assignable to type 'number'. |
| 75 | + rest("e", ...mixed) |
| 76 | + ~~~~~~~~ |
| 77 | +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 78 | +!!! error TS2345: Type 'string' is not assignable to type 'number'. |
| 79 | + rest("f", ...tuple) |
| 80 | + ~~~~~~~~ |
| 81 | +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. |
| 82 | +!!! error TS2345: Type 'string' is not assignable to type 'number'. |
| 83 | + prefix(...all) // required parameters are required |
| 84 | + ~~~~~~~~~~~~~~ |
| 85 | +!!! error TS2346: Supplied parameters do not match any signature of call target. |
| 86 | + ~~~ |
| 87 | +!!! error TS2461: Type '(a?: number, b?: number) => void' is not an array type. |
| 88 | + prefix(...mixed) |
| 89 | + ~~~~~~~~~~~~~~~~ |
| 90 | +!!! error TS2346: Supplied parameters do not match any signature of call target. |
| 91 | + prefix(...tuple) |
| 92 | + ~~~~~~~~~~~~~~~~ |
| 93 | +!!! error TS2346: Supplied parameters do not match any signature of call target. |
| 94 | + |
0 commit comments