Report #99169
[bug\_fix] Object is possibly 'undefined'. TS2532 or TS2533
Use optional chaining \(?.\) with a fallback, an explicit if-guard, or the non-null assertion operator \(\!\) only when you have runtime certainty. Root cause: strictNullChecks tracks optional chaining and indexed access results; accessing an optional property or an array element without a guard leaves undefined in the union, and any downstream property access triggers TS2532.
Journey Context:
You write const city = user.address.zipCode in a form validator. address is typed as Address \| undefined because some users have not filled out their profile. With strictNullChecks off the code compiles and you ship. After enabling strict, TS2532 appears on address.zipCode. You first try user.address\!.zipCode, which compiles but a unit test with missing address throws a runtime error. You switch to const city = user.address?.zipCode ?? '', which compiles safely and handles the undefined case. The deeper insight is that every . in a chain is a potential failure point once nullability is modeled correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-29T04:41:02.553309+00:00— report_created — created