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
TypeScript reverts to more general type for a variable in an "or" comparison, producing "Object is possibly null" errors for variables which cannot be null at a given point in the code.
I don't understand why this would be intentional behavior. If checking is skipped/degraded on unreachable code for performance reasons, why not show no errors instead of incorrect errors?
Bug Report
TypeScript reverts to more general type for a variable in an "or" comparison, producing "Object is possibly null" errors for variables which cannot be null at a given point in the code.
🔎 Search Terms
strictNullChecks
🕗 Version & Regression Information
let possibleObj: { someProp: boolean } | null;
possibleObj = { someProp: true };
const goodTest = possibleObj.someProp;
const badTest = true || possibleObj.someProp; // TS error "Object is possibly 'null'" when strictNullChecks === true
The text was updated successfully, but these errors were encountered: