Closed as not planned
Closed as not planned
Description
π Search Terms
"Inferred Type Predicates"
π Version & Regression Information
5.6.0-dev.20240801
β― Playground Link
π» Code
type O = { key: string };
const objs: (O | null)[] = [{ key: 'a' }, { key: 'b' }, null];
const filtered1 = objs.filter(s => s != null); // O[]
const filtered2 = objs.filter(s => s != null && s.key == 'a'); // (O | null)[]
const filtered3 = objs.filter(s => s != null).filter(s => s.key == 'a'); // O[]
π Actual behavior
The type inferred for filtered2
is (O | null)[]
instead of O[]
.
π Expected behavior
I would expect filtered2
to have the inferred type O[]
, similar to filtered1
and filtered3
.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
No labels