TS2533: Object is possibly null or undefined - in CI
A value whose type includes both null and undefined was used without narrowing.
What this error means
Type-checking fails with TS2533 at access on a value typed as T | null | undefined.
tsc
src/find.ts(9,5): error TS2533: Object is possibly 'null' or 'undefined'.Common causes
How to fix it
Narrow both cases
- A truthy check rules out both null and undefined for object types
ts
if (node) traverse(node)Default with nullish coalescing
- Provide a fallback so the value is never null/undefined downstream
ts
const value = maybe ?? fallbackHow to prevent it
- Model nullability explicitly and narrow once at the boundary instead of repeatedly asserting.
Related guides
TS2531: Object is possibly null - in CIFix "error TS2531: Object is possibly 'null'" when tsc runs in CI under strictNullChecks - guard the value be…
TS2532: Object is possibly undefined - in CIFix "error TS2532: Object is possibly 'undefined'" when tsc runs in CI - guard array/optional access before u…
TS18049: Value is possibly null or undefined - in CIFix "error TS18049: 'x' is possibly 'null' or 'undefined'" when tsc runs in CI - narrow a T | null | undefine…