-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Order of expressions in if block affect type narrowing from unknown #34334
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
Labels
Duplicate
An existing issue was already created
Comments
Duplicate of #28131 |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
LotharKAtt
added a commit
to ExaForce/TypeScript
that referenced
this issue
Mar 17, 2025
LotharKAtt
added a commit
to ExaForce/TypeScript
that referenced
this issue
Mar 18, 2025
vaclav-dvorak
added a commit
to ExaForce/TypeScript
that referenced
this issue
Mar 18, 2025
Freeze GitHub Actions (microsoft#34334)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeScript Version: 3.7-Beta
Search Terms: object null order type narrowing
Code
Playground link
Expected behavior:
No type errors;
maybeObject
is correctly narrowed toobject
in both cases.Actual behavior:
The first if block throws an error as
maybeObject
is incorrectly narrowed toobject | null
, whereas the secondmaybeObject
is incorrectly narrowed.Playground Link: http://www.typescriptlang.org/play/?ts=3.7-Beta&ssl=1&ssc=1&pln=9&pc=2#code/MYewdgzgLgBAtgQwJ4CMCmB5FArNwoBcMArmANZggDuYMAvDAN4C+A3AFDsCWAZjABSJUmHHlgBCBmGIAbGTABkCmFCQAHNCD5D0WXPnp0GAchCj8xgJRN2MOzD1iAdGTRIIg5LvNRL7Zpy8AqoaWvBeIvqwRiZmUcaKyjqRYjCSMNJy1oy29o74Lm4eyfm+-kA
Related Issues: No
The text was updated successfully, but these errors were encountered: