-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Closed
Copy link
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
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.
Metadata
Metadata
Assignees
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript