Contextual parameters inferred from overloads improvements #59350
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
π Search Terms
contextual parameters functions overloads inference TS7006 argument length
β Viability Checklist
β Suggestion
Currently, inferring a parameter type from a function with overloads is very finicky. Unused generic parameters, constraints, and parameter length all unnecessarily prevent parameter types from being inferred.
A lot of these limitations are mentioned on #42620, but there's no inherent reason the parameters can't be inferred in many of these cases. This is a suggestion to revisit some of the merge logic to allow a wider variety of cases to be inferred correctly.
π Motivating Example
Here are some examples I've run into recently that I believe are reasonable inference candidates:
Playground: https://tsplay.dev/N5YkVN
π» Use Cases
The text was updated successfully, but these errors were encountered: