Report #70987
[bug\_fix] Object is possibly 'undefined'.
Use optional chaining \(user?.name\) to safely access properties, add an explicit null check \(if \(user\) \{ ... \}\) to narrow the type, or use a non-null assertion \(\!\) only when certain the value exists.
Journey Context:
Developer has code const user = await getUser\(\); console.log\(user.name\). With strictNullChecks enabled, TS errors "Object is possibly 'undefined'". The developer knows getUser never returns null in practice, but the return type is Promise. They try adding if \(\!user\) return; which narrows the type. They try user\!.name which silences it but is risky. They learn about optional chaining user?.name, which safely returns undefined if user is nullish, satisfying the type checker without runtime errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:43:33.823470+00:00— report_created — created