strictNullChecks false positives for non-null object propertiesΒ #60847
Closed as not planned
Description
π Search Terms
possibly null undefined object property
π Version & Regression Information
Originally detected with 5.7.2, but also confirmed in v5.8.0-dev.20241223 via the playground.
β― Playground Link
π» Code
let x: number | null = 5;
let y = x + 5; // no problem
let obj: {x: number | null} = {x: 5};
let z = obj.x + 5; // error: 'obj.x' is possibly 'null'. (18047)
π Actual behavior
When nullable object properties have been assigned a non-null value, TS still considers them "possibly null", even though it does not for equivalently typed variables.
π Expected behavior
No error.
Additional information about the issue
No response
Activity