-
Notifications
You must be signed in to change notification settings - Fork 12.8k
[5.4 regression] Conditional type changes behavior with 5.4-beta #57221
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
bisected to #56515 |
I can confirm that The |
I feel like this is the same problem that breaks the inference in MikroORM for the populate hints (and many other things that work on the same basis), it starts to break with If this is considered WAI, I am honestly scared... π€£ The use case on our end is more complex than just validation, we need inference so the types can be used in the return values. Will work on the repro and open a new issue soon'ish, just wanted to bring this up, as I feel a storm is coming (already got a report about this some time ago). edit: solved via mikro-orm/mikro-orm#5197 |
The difference here is in the type parameter inference. In 5.4 we get
whereas in 5.3 it's only
Generic inference has always been willing, in other cases, to produce a string literal union:
so it's at least somewhat apparent that the 5.3 behavior is the incorrect (or at least inconsistent) one. |
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
π Search Terms
5.4 regression
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.4.0-dev.20240129#code/KYDwDg9gTgLgBDAnmYcCiIZQIYGMYBKEArjMAArY4C2AzgDwAqcoZAdgCa1y1YCWbAOYA+OAF4e-IS0zBO3RgFgAUHDgB+OAWC5oHerygDBAGklGhwlWoBccZqzlc4AAwAkAbwEAzYFDgA+gDKMFQwAL42nj5+cJQ04QD00Wy+-tq84S7WGnAecADaANZwAnFU2NRwAD5wRcCIEN7omDj4RKQUFXT0GTDCALp2hsZw4Tl2DrLyrilpgSFhkXOx8ZVZOZr5xaVs5TRD5qPjqnB2HuEA3CoqHDoANlSo3sRs+HwQe-cCRUwy7M4RpYABQ5KiCWjnHJqMDYGAAC0m11O4TgADI4MCLv8nNwMFg8IQSGQ1j1GKItnBYTRaOpzqjUecqd1IS0Ce1iV0aUxROEAJQmFR8uwANwgfA4yJUiUSLCgUGguwQ3AArAA6ADMmrg2E4cHVABY1QAGAC0ACNgKEVN82EUscyEXYAOSJGzeCAQN3mqjOszUyqs7H85EyuUK-xlGCqzWasxsCDhxVRmNGs2W0JquBBeEke4cOCWnV7PwRtU2n4O2FOuCu92e71URJ+5k0pkeiAujvOsZjPnIoA
π» Code
π Actual behavior
The last line is only an error in TS 5.3.3, not TS 5.4-beta.
π Expected behavior
I'd expect it to be an error in both (
foo
isn't specified).Additional information about the issue
Putting
NoInfer
in the conditional type makes the expected error reappear:So perhaps this is WAI? Just wanted to flag it as a change I noticed from 5.3.3 to 5.4-beta.
The text was updated successfully, but these errors were encountered: