|
| 1 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(16,1): error TS2554: Expected 1 arguments, but got 0. |
| 2 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(19,1): error TS2554: Expected 1 arguments, but got 0. |
| 3 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(22,1): error TS2554: Expected 1 arguments, but got 0. |
| 4 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(35,31): error TS2554: Expected 1 arguments, but got 0. |
| 5 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(36,35): error TS2554: Expected 1 arguments, but got 0. |
| 6 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(37,33): error TS2554: Expected 1 arguments, but got 0. |
| 7 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(48,1): error TS2554: Expected 3 arguments, but got 1. |
| 8 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(55,1): error TS2554: Expected 4 arguments, but got 2. |
| 9 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(56,1): error TS2554: Expected 4 arguments, but got 3. |
| 10 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(57,1): error TS2554: Expected 4 arguments, but got 1. |
| 11 | +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1): error TS2554: Expected 3 arguments, but got 1. |
| 12 | + |
| 13 | + |
| 14 | +==== tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts (11 errors) ==== |
| 15 | + // From #4260 |
| 16 | + class X<T> { |
| 17 | + f(t: T) { |
| 18 | + return { a: t }; |
| 19 | + } |
| 20 | + } |
| 21 | + |
| 22 | + declare const x: X<void>; |
| 23 | + x.f() // no error because f expects void |
| 24 | + |
| 25 | + declare const xUnion: X<void | number>; |
| 26 | + xUnion.f(42) // no error because f accepts number |
| 27 | + xUnion.f() // no error because f accepts void |
| 28 | + |
| 29 | + declare const xAny: X<any>; |
| 30 | + xAny.f() // error, any still expects an argument |
| 31 | + ~~~~~~~~ |
| 32 | +!!! error TS2554: Expected 1 arguments, but got 0. |
| 33 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:3:7: An argument for 't' was not provided. |
| 34 | + |
| 35 | + declare const xUnknown: X<unknown>; |
| 36 | + xUnknown.f() // error, unknown still expects an argument |
| 37 | + ~~~~~~~~~~~~ |
| 38 | +!!! error TS2554: Expected 1 arguments, but got 0. |
| 39 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:3:7: An argument for 't' was not provided. |
| 40 | + |
| 41 | + declare const xNever: X<never>; |
| 42 | + xNever.f() // error, never still expects an argument |
| 43 | + ~~~~~~~~~~ |
| 44 | +!!! error TS2554: Expected 1 arguments, but got 0. |
| 45 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:3:7: An argument for 't' was not provided. |
| 46 | + |
| 47 | + |
| 48 | + // Promise has previously been updated to work without arguments, but to show this fixes the issue too. |
| 49 | + |
| 50 | + class MyPromise<X> { |
| 51 | + constructor(executor: (resolve: (value: X) => void) => void) { |
| 52 | + |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + new MyPromise<void>(resolve => resolve()); // no error |
| 57 | + new MyPromise<void | number>(resolve => resolve()); // no error |
| 58 | + new MyPromise<any>(resolve => resolve()); // error, `any` arguments cannot be omitted |
| 59 | + ~~~~~~~~~ |
| 60 | +!!! error TS2554: Expected 1 arguments, but got 0. |
| 61 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:28:38: An argument for 'value' was not provided. |
| 62 | + new MyPromise<unknown>(resolve => resolve()); // error, `unknown` arguments cannot be omitted |
| 63 | + ~~~~~~~~~ |
| 64 | +!!! error TS2554: Expected 1 arguments, but got 0. |
| 65 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:28:38: An argument for 'value' was not provided. |
| 66 | + new MyPromise<never>(resolve => resolve()); // error, `never` arguments cannot be omitted |
| 67 | + ~~~~~~~~~ |
| 68 | +!!! error TS2554: Expected 1 arguments, but got 0. |
| 69 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:28:38: An argument for 'value' was not provided. |
| 70 | + |
| 71 | + |
| 72 | + // Multiple parameters |
| 73 | + |
| 74 | + function a(x: number, y: string, z: void): void { |
| 75 | + |
| 76 | + } |
| 77 | + |
| 78 | + a(4, "hello"); // ok |
| 79 | + a(4, "hello", void 0); // ok |
| 80 | + a(4); // not ok |
| 81 | + ~~~~ |
| 82 | +!!! error TS2554: Expected 3 arguments, but got 1. |
| 83 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:42:23: An argument for 'y' was not provided. |
| 84 | + |
| 85 | + function b(x: number, y: string, z: void, what: number): void { |
| 86 | + |
| 87 | + } |
| 88 | + |
| 89 | + b(4, "hello", void 0, 2); // ok |
| 90 | + b(4, "hello"); // not ok |
| 91 | + ~~~~~~~~~~~~~ |
| 92 | +!!! error TS2554: Expected 4 arguments, but got 2. |
| 93 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:50:34: An argument for 'z' was not provided. |
| 94 | + b(4, "hello", void 0); // not ok |
| 95 | + ~~~~~~~~~~~~~~~~~~~~~ |
| 96 | +!!! error TS2554: Expected 4 arguments, but got 3. |
| 97 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:50:43: An argument for 'what' was not provided. |
| 98 | + b(4); // not ok |
| 99 | + ~~~~ |
| 100 | +!!! error TS2554: Expected 4 arguments, but got 1. |
| 101 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:50:23: An argument for 'y' was not provided. |
| 102 | + |
| 103 | + function c(x: number | void, y: void, z: void | string | number): void { |
| 104 | + |
| 105 | + } |
| 106 | + |
| 107 | + c(3, void 0, void 0); // ok |
| 108 | + c(3, void 0); // ok |
| 109 | + c(3); // ok |
| 110 | + c(); // ok |
| 111 | + |
| 112 | + |
| 113 | + // Spread Parameters |
| 114 | + |
| 115 | + declare function call<TS extends unknown[]>( |
| 116 | + handler: (...args: TS) => unknown, |
| 117 | + ...args: TS): void; |
| 118 | + |
| 119 | + call((x: number, y: number) => x + y) // error |
| 120 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 121 | +!!! error TS2554: Expected 3 arguments, but got 1. |
| 122 | +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:73:5: An argument for 'args' was not provided. |
| 123 | + call((x: number, y: number) => x + y, 4, 2) // ok |
| 124 | + |
| 125 | + call((x: number, y: void) => x, 4, void 0) // ok |
| 126 | + call((x: number, y: void) => x, 4) // ok |
| 127 | + call((x: void, y: void) => 42) // ok |
| 128 | + call((x: number | void, y: number | void) => 42) // ok |
| 129 | + call((x: number | void, y: number | void) => 42, 4) // ok |
| 130 | + call((x: number | void, y: number | void) => 42, 4, 2) // ok |
| 131 | + |
0 commit comments