noUncheckedIndexedAccess enabled
Why it matters
noUncheckedIndexedAccess is not covered by the strict umbrella — it must be set explicitly, and most TypeScript projects never do. Without it, array[0] is typed as T even when the array is empty, so array[0].name compiles fine and throws Cannot read properties of undefined at runtime. ISO 25010:2011 §6.5.4 flags this as a reliability defect. This is one of the highest-signal, lowest-friction compiler flags available: it adds | undefined to every index access and forces you to handle the empty case.
Severity rationale
Critical because every array index access in the codebase is a potential undefined crash that the compiler is actively hiding from you — one empty API response is enough to trigger it.
Remediation
Add "noUncheckedIndexedAccess": true to your tsconfig.json compilerOptions. It is not implied by strict: true, so it must be explicit. The flag will surface every unguarded array access — fix them with optional chaining or an explicit undefined check.
// Before (unsafe — crashes if items is empty):
const first = items[0].name;
// After (safe):
const first = items[0]?.name;
// or:
const item = items[0];
if (item !== undefined) { console.log(item.name); }
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true
}
}
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Code Quality Essentials Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · maintainability.modifiability — Maintainability — Modifiability
Taxons
History
- 2026-04-18·v1.0.0·Initial import from code-quality-essentials·automated