Skip to content
Latchkey

TS2532: Object is possibly undefined - in CI

You used a value that can be undefined without checking it first.

What this error means

Type-checking fails with TS2532, commonly on optional properties or indexed array access under noUncheckedIndexedAccess.

tsc
src/list.ts(7,3): error TS2532: Object is possibly 'undefined'.

Common causes

How to fix it

Guard or default the value

  1. Check for undefined, use optional chaining, or supply a default with ??
ts
const first = items[0]
if (first) use(first)

Narrow with optional chaining

  1. Chain member access so undefined short-circuits safely
ts
const name = user?.profile?.name ?? "anon"

How to prevent it

  • Handle optional and indexed values explicitly; noUncheckedIndexedAccess surfaces these before runtime.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →