Closed
Description
Bug Report
π Search Terms
tuple arguments trailing elements contextual type
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
Playground link with relevant code
π» Code
declare function test(
...args: [...((arg: number) => void)[], (arg: string) => void]
): void;
test(
(a) => {
a
// ^? actual: any; expected: number
},
(b) => {
b
// ^? actual: any; expected: number
},
(c) => {
c
// ^? actual: any; expected: string
},
);
π Actual behavior
Contextual parameters can't be inferred.
π Expected behavior
Contextual parameters should be inferred.
Quoting @ahejlsberg from here:
This would require us to reason about elements at a fixed offset from the end of a tuple. We currently only reason about elements at a fixed offset from the start. It adds some more complexity, but it is certainly possible to do.