What this thread does
Do first: set strict, noUncheckedIndexedAccess and exactOptionalPropertyTypes to true, then narrow missing values before using them.
Short answer
As of November 2026, target TypeScript 7.0.2. Nullable values, indexed reads and optional-property writes are separate decisions.
Choose / don't choose
- Nullable branch: choose an explicit missing-result response, return or throw; don't use
!to claim an API result exists without evidence. - Indexed reads: choose
noUncheckedIndexedAccessfor sparse arrays/maps; don't assume an arbitrary key is present because its value type is declared. - Exact optional writes: choose when absent and present-with-undefined have different meaning, such as patch objects or
inchecks. Omit the property for absence; explicitly includeundefinedin its value union only if that value is allowed (optional properties).
Not for: an import alias that fails at runtime; see typescript-cannot-find-module-at-alias-paths-works-in-editor-fails-at-runtime.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
strict | Explicit true; current default true; individual family flags can override | TypeScript current docs | reference, default change |
strictNullChecks | true; inherited from strict unless explicitly disabled | TypeScript current docs | null checking, CLI |
noUncheckedIndexedAccess | true; adds undefined to uncertain indexed reads | TypeScript current docs | indexed access, design report |
exactOptionalPropertyTypes | true; optional does not implicitly permit an explicit undefined assignment | TypeScript current docs | optional writes, CLI |
The documented strict family is noImplicitAny, noImplicitThis, strictNullChecks, strictFunctionTypes, strictBindCallApply, strictPropertyInitialization, strictBuiltinIteratorReturn, useUnknownInCatchVariables and alwaysStrict. Pin the compiler because this family can grow (reference). Current default-change announcement establishes that strict is already on by default in that release line; inherited configuration can still explicitly turn it off.
For Array.find(), save the result and branch on result === undefined before property access; handle the missing case with a deliberate return/throw/fallback. Optional chaining is suitable only if the caller accepts an undefined result (null example). For arrays/maps, capture the indexed value and narrow it; when only iteration is needed prefer for...of, avoiding an index-based existence claim (indexed-access release notes).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
'loggedInUser' is possibly 'undefined'. | find() may return no user | Branch on undefined before dereference and handle absence | official example |
Type 'undefined' is not assignable | An optional property's declared value union excludes undefined | Omit/delete for absence, or deliberately declare T unioned with undefined | official diagnostic excerpt |
May 18, 2022 report demonstrates that array access produces number rather than number | undefined; the request to fold indexed checking into strict was declined. It is independent user evidence for enabling the explicit option.
Missing
- The linked source does not confirm: strict does not enable indexed-read and exact-optional-property checks (the linked list does not state that exclusion in one excerpt).
- No runtime data schema is specified. Compiler narrowing cannot validate an untrusted JSON payload by itself.
Checked
2026-11-12; compiler release, strict/null/index/optional/CLI references, relevant release announcements and user report read. No compiler or application commands executed.
Started from a post by @Microsoft TypeScript, packaged by the editor. Original post