-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Regression 5.4: the new conditional type constraint is not working with a type parameter representing union type #57864
Comments
I think this is working as intended in TypeScript 5.4:
The way you can get around this is by either
|
@DanielRosenwasser Thank you for taking a look, this is probably the change that cause the error! But here the situation is right the opposite of how it says it should work: The difference between |
So without having been deeply in the guts of conditional type instantiation, I'm going to do my best on this one! From the #56004:
So previously, So we'd always jump into the negative case and end up with
As you can see from the examples, that's not correct though! An
Not sure exactly what you mean, but it might be related to a tradeoff we consciously made. The new behavior only kicks in on higher-order types (i.e. type parameters). In other words, if you pass in |
@DanielRosenwasser, I'm terribly sorry. I made a typo when simplifying the initial code. Of course, I will take another try to simplify the initial code to a short snippet tomorrow. Thank you for your time, I truly appreciate your effort in taking a look at the issue! |
This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
🔎 Search Terms
regression, type parameter, 5.4
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.4.2#code/C4TwDgpgBAggznAlgcwHYCUJwK4BtgA8MATsVBAB7ASoAmcUA9gEYBWEAxsANoC6AfFAC8sUgCgxAeklRuqPLgA0UeQFtmEYsux0IAM0SoItZXGDFDyXsMFzs6zafOXeY0JCgAxRPk1FSygAqjADyqojAgiIkZJTUdAzchnqaUAASEACGJlAAdPnJqYGZPq5QUAD86Vm05FQ09FDBYRFi5eVV3r7EBMU+QaHhkW3tAFyyGdnK+bld1D19Sk2DEfxlUON8ANwS7tAA6ozEANZwAAoWRwCsACwEAMp18Y0s7FxQAD4qClGwCCgYLB4QhzPz3ZTyXC4fj8XbgA5HU7CP5INCYHD4AignqvTjAT7fKEQn78IA
💻 Code
This is the simplified code
This is the full code (error message is slightly different, but probably they are the same):
🙁 Actual behavior
I would expect to have no error for 5.4, the same as there was no error before it. Especially considering that there were not breaking changes in 5.4 announcement.
As for the simplified code, there should be no difference between how
WorksPrior54
andWorks
.As for the full version of the code, there should be no difference if part of
Sources
type parameter is extracted into an intermediateSource
type parameter, or not🙂 Expected behavior
Error (in the simplified version):
Error (in the full version):
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: