Enable noUncheckedIndexedAccess in app tsconfigs
Problem¶
Shared packages (widget-wire-schemas, widget-renderers, portable-text) already set noUncheckedIndexedAccess: true, but the apps' tsconfigs do not. This means arr[i] and map.get(k) are inferred as their element type with no | undefined, hiding a class of runtime bugs.
- apps/cms/tsconfig.json — strict, but missing
noUncheckedIndexedAccess. - apps/lms/tsconfig.json — same gap.
Proposal¶
- Enable
noUncheckedIndexedAccess: truein both app tsconfigs. - Run
npm run typecheckand fix fallout iteratively. Expected hotspots:- Pagination helpers slicing arrays.
- Map-based RBAC lookups in
apps/cms/src/lib/rbac/*. - Kysely result destructuring (
rows[0]).
- Use explicit guards (
if (!row) throw ...) rather than non-null assertions where possible. Where a non-null assertion is genuinely correct, add a brief comment explaining why. - Do not introduce
// @ts-expect-errorto silence failures.
Acceptance criteria¶
-
noUncheckedIndexedAccess: trueset in both app tsconfigs (andpackages/ui). -
npm run typecheckis green for both apps. - No new
// @ts-ignore/// @ts-expect-erroradded. -
npm run checkpasses.
Out of scope¶
- Tightening other strictness flags (
exactOptionalPropertyTypes,noPropertyAccessFromIndexSignature). - Refactoring code beyond what the new check forces.
Notes / decisions log¶
- 2026-05-24: Ticket created from monorepo audit.
- 2026-05-25: Implemented bundled with T-008: enabled flag on
apps/lms,apps/cms, andpackages/ui; fixed ~58 LMS and ~393 CMS indexed-access errors; added sharedgetInitialsat@open-learning-hub/ui/lib/get-initials; CMS test helpers (src/test/expect-defined.ts,kysely-chain-mock.ts,store-test-helpers.ts). Re-rated effort medium (CMS Zustand stores + test fixtures dominated lift).