-
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
ReturnType<SomeClass["someMethodWithOverloads"]> incorrect result #42510
Comments
Conditional types do not work with overloads. This is mentioned in the documentation. |
I see. I wish the Conditional Types page on the typescript website made this clearer. Thank you, Martin for explaining and sorry I didn't catch this before I made this issue! Feel free to close it. |
For anyone that stumbles upon this issue I mistakenly made, here are a couple of related links:
I clearly was not looking hard enough. Again, sorry. |
Type inference in conditional types
But I've noticed that the v2 handbook (which is marked as work in progress) does not mention this constraint at all. |
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
If you shuffle the order of the overload definitions, the last one (the non-implementation one) becomes the type given by
ReturnType<Class["method"]>
.🙂 Expected behavior
The return type indicated by the method signature that provides the function body should be given by
ReturnType<Class["method"]>
The text was updated successfully, but these errors were encountered: