-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Type union collapses into the general type in condition #55158
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
This is working as intended and happens because of type reduction. See #50171 and many many others. Also: https://www.typescriptlang.org/docs/handbook/type-inference.html#best-common-type |
@MartinJohns thanks your help and reference links. |
but I don't think this reduction is meaningful to the developers. it lost information that should be there. |
@Jack-Works Variations of this same issue have been raised many, many times in the past and the response by maintainers is consistently that subtype reduction, while sometimes inconvenient, is not only not considered to be a bug, but completely by design, so it's very unlikely you're going to get much traction on this. #53425 (comment) |
Bug Report
π Search Terms
type union collapses
π Version & Regression Information
3.3.3
to5.2.0-beta
and the result are the same.β― Playground Link
Playground link
π» Code
π Actual behavior
π Expected behavior
The text was updated successfully, but these errors were encountered: