-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Truthiness narrowing does not work as expected with &&
#52822
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
After the first check, |
I've been trying to state this in a reasonable way for years and you finally provided a phrasing that makes sense π |
Bug Report
π Search Terms
π Version & Regression Information
Possibly related to #52272
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
TypeScript fails to narrow the type of
shape.x
tonumber
only infn1
after the first conditional branchif (shape.kind === "square" && shape.x === null)
ππ Expected behavior
After the first conditional branch
if (shape.kind === "square" && shape.x === null)
infn1
,shape.x
can not benull
anymore.However, doing just
if (shape.x === null)
infn2
works fineThe text was updated successfully, but these errors were encountered: