Enable noUncheckedIndexedAccess to catch out-of-bounds array bugs

SkillDev tools

no-unchecked-indexed-access is a skill for auditing TypeScript projects and reviewing code that uses array index access. It guides an agent through checking whether the noUncheckedIndexedAccess flag is enabled in tsconfig.json, scanning for index accesses that could yield undefined, and fixing them with explicit checks or optional chaining. It is useful when investigating runtime undefined errors that TypeScript did not catch.

Available today. Use it from your connected AI after setup.

Have a TypeScript project with a tsconfig.json file available.

Then ask your AI: use the Enable noUncheckedIndexedAccess to catch out-of-bounds array bugs skill

What your AI can do with it

  • Audit tsconfig.json for the missing noUncheckedIndexedAccess safety flag
  • Review array index accesses (arr[0], arr[i], object[key]) for missing undefined checks
  • Investigate runtime undefined errors that TypeScript did not catch
  • Enable noUncheckedIndexedAccess and update flagged accesses with explicit checks
  • Explain how optional chaining and Array.at() interact with the flag

Getting started

  1. Have a TypeScript project with a tsconfig.json file available.
  2. Ask the agent to check whether noUncheckedIndexedAccess is enabled in tsconfig.json.
  3. If it is not enabled, have the agent scan for array index accesses that could fail on short arrays.
  4. Enable the flag in tsconfig.json and update flagged accesses with undefined checks or optional chaining.
  5. Optionally ask for a code review of index accesses even before the flag is enabled.

What this skill tells your AI

The instructions your AI receives, as published by thedaviddias/front-end-checklist in skills/no-unchecked-indexed-access/SKILL.md and read by ahel’s review.

TypeScript's default behaviour types array[0] as T, pretending the access is always safe. In reality, the array might be empty or the index might be out of range, leading to silent undefined values that cause downstream crashes. Enabling noUncheckedIndexedAccess surfaces these potential failures as type errors at compile time, requiring developers to prove the access is safe before the code runs.

Quick Reference

  • Without the flag, array[0] is typed as T even if the array is empty
  • noUncheckedIndexedAccess changes array[n] to return T | undefined
  • Forces an explicit check before using any array element accessed by index
  • Optional chaining and nullish coalescing handle most false positives cleanly

Check

Check whether noUncheckedIndexedAccess is enabled in the project's tsconfig.json. If not, scan for array index accesses (arr[0], arr[i]) that could fail if the array is shorter than expected.

Fix

Enable noUncheckedIndexedAccess in tsconfig.json, then update any array index accesses that TypeScript now flags to include an explicit undefined check or use optional chaining before the accessed value is used.

Explain

Explain what noUncheckedIndexedAccess does, why the default TypeScript behaviour is unsound for array index access, and how optional chaining and Array.at() interact with the flag.

Code Review

Review all array index accesses in this file (arr[0], arr[i], object[key]). Flag any location where the accessed value is used without a preceding undefined check, even if noUncheckedIndexedAccess is not yet enabled in the project.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/en/rules/javascript/no-unchecked-indexed-access

Signals

GitHub stars
74k
Forks
7k
Last commit
Aug 2026

Questions

What does noUncheckedIndexedAccess do?
It changes array[n] to return T | undefined instead of T, so TypeScript flags out-of-bounds accesses at compile time and forces an explicit check before an accessed element is used.
Why is the default TypeScript behaviour unsound for array index access?
By default array[0] is typed as T even if the array is empty, so silent undefined values can flow through code and cause downstream crashes that the type system did not catch.
Advanced
Item type
skill
Key
no-unchecked-indexed-access
Source
github.com/thedaviddias/front-end-checklist