Type narrowing fails to account for multiple conditions #53072
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Bug Report
π Search Terms
type narrowing
π Version & Regression Information
β― Playground Link
https://tsplay.dev/mAJ91W
π» Code
π Actual behavior
The
y
in1 / y
has a type error.π Expected behavior
Since this is inside a block where
x === y
, and also wherex === 0
, TS should be able to statically know thatx
andy
are of typenumber
(since both of them is definitively a zero, either+0
or-0
). I shouldn't need they === 0
check just to please TS.The text was updated successfully, but these errors were encountered: