-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why do we need to manually type unified overload signatures? #25352
Comments
Actually, it would be, with the caveat that it wouldn't break any code using |
I had a PR that implemented this awhile ago and it langushied for a long time. @DanielRosenwasser if we actually want to look at it, I can refresh it again. There are some issues, like generic unification and debate of what the correct contextual return type is (union or intersection). |
I'd like to +1 this as a feature request -- I have a use case where |
Please close if this has been asked before - nothing came up when searching.
Search Terms
overload, function, multiple, default, combine, unify, top
Suggestion
Today, when defining an overloaded call signature you have to manually type the implementation. Would it be possible to extend contextual types so TS can infer the implementation's types from context, just like TS already does for non-overloaded signatures?
Use Cases
Today, contextual typing isn't able to infer parameter types for overloaded call signatures. Instead, users have to manually type the implementation.
Examples
Before
After
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: