-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Template types don't resolve in conditional types #59749
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
Hi, I took a look at the other issues and I'm a bit confused. Why would it make sense for the type to resolve when it's a type but not when it's a generic? |
Because the compiler does not know what type |
Is it impossible to take the type into consideration? To me this case seems pretty clear cut that it would make sense to resolve the type, no? It's a bit weird because the generic has the same constraint that's on the type and the type is able to resolve, so I think it makes perfect sense to resolve the type in this case. Is the problem that with types you're able to use deferred/lazy resolution and make sure that it's 100% okay whereas with the generic you don't do that because of problems with transitivity? It seems like the problems with transitivity are limited to a few specific cases. Wouldn't it be possible to compute the types in a way that avoids those problems but still let's clear cut cases like this be resolved correctly? Regardless, this was something extremely confusing and it should probably be better documented. The error I got did nothing to point me in the right direction and the whole non-transitivity problem is definitely not something most developers are thinking about so it's unintuitive that the type constraints aren't taken into consideration |
Also, I appreciate you taking the time to triage/discuss this issue π₯ |
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
I can't find the issue, but somewhere the team mentioned that it's not worth the cost, as the cases where this can be resolved are edge cases.
Please note that I am not a team member. |
π Search Terms
conditional types, resolve, template
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.7.0-dev.20240825#code/C4TwDgpgBAglC8UDeAoKUCGAuKBnYATgJYB2A5igL4oqiRQBCCyaUARjvseVTXdAFkQAFXAQAPMKgQAHsAgkAJrlhQAPowB8zFFNnylKuAH4oAcgxmoOM2zM0AZgFcSAY2BEA9iSgPPnyWk5BWVYTQAKAEocADdPIkUWdFdvfCgZHCFRSEltRAt7dBkqIA
π» Code
π Actual behavior
Type "a" is not assignable to MyType
π Expected behavior
Type "a" is assignable to MyType
Additional information about the issue
This additional snippet works as expected:
The text was updated successfully, but these errors were encountered: