-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Generic parameters info is not inferred in conditional types over ancestor #55146
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
Comments
Because you have unused type parameters. Why doesn't type inference work on this interface:
See also this comment. |
Yes, but it does work for |
And it will work for
|
Yes, thank you, that's my question. Why does it allow inferring over unused type parameters in this case but doesn't in another one. |
That I don't know. Like I said, I don't know the implementation details of the compilers algorithms in detail. It's probably just an edge case where the type parameter can be taken directly from the declared type, instead of having to actually perform an inference by navigating the type backwards. Maybe someone else can chime in, but generally this repository is not meant for questions. All I can say is that it's working as intended. This issue is basically the same and closed as |
it's because |
To add to @Andarist 's answer: generic inference can take a "shortcut" when relating |
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
In conditional type over an interface
X
,infer
seems not to work for generic parameters when applied to interfaceY extends X
.🔎 Search Terms
generic, infer, conditional, interface, extends
🕗 Version & Regression Information
It occurs in all tested versions – including latest, nightly, and some older ones.
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Got
unknown
.🙂 Expected behavior
Expected to get
{foo: string}
.The text was updated successfully, but these errors were encountered: