You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is working as intended. There are no one-sided typeguards.
The second case cannot be inferred as s is O, because if s.key != 'a', s can still be O.
π Search Terms
"Inferred Type Predicates"
π Version & Regression Information
5.6.0-dev.20240801
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.6.0-dev.20240801#code/C4TwDgpgBA8lC8UDeUDWEQC4oGdgCcBLAOwHMoBfAbgCgBjAe2LygYCMArHbACjgB8oxAK4AbUQEoA2gF0EUKSnRYoAcgCGqygBpkaDNlVstFXSPEzajZsCgAzQqOAR8EACYBGeey4A6B04uPDgIAHy4UACEiOaSVFAA9AmwsvRMLAHOrm4ATN6cOP6OWcFhEdFCYqJQAGQ1uL7KCIgaqhLxSVB8UIKx0jJpNvbFLu4AzPl+mUEh8OEhFX1Fgfilcw1N8C2a7YnJMKlAA
π» Code
π Actual behavior
The type inferred for
filtered2
is(O | null)[]
instead ofO[]
.π Expected behavior
I would expect
filtered2
to have the inferred typeO[]
, similar tofiltered1
andfiltered3
.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: