no-unchecked-indexed-access
What it does
This skill checks whether the TypeScript safety option noUncheckedIndexedAccess is on, and fixes code that reads array items by index without checking them. It is for developers who want fewer runtime undefined errors.
When to use it
- ✓When you ask the agent to check the TypeScript settings of a project for missing safety options.
- ✓When your app crashes with undefined values that TypeScript did not warn about.
- ✓When you are reviewing data processing code that reads items from arrays by position.
Skill link
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/no-unchecked-indexed-access/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“My app sometimes crashes with undefined errors. Can you turn on the TypeScript setting that catches these and fix the code it flags?”
5 new skills a week. 1 minute to read.
How it works
The agent checks the tsconfig.json file and turns on the option if it is missing. It then updates the array accesses that TypeScript now flags, adding checks or optional chaining so the code handles missing items.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Enable noUncheckedIndexedAccess to catch out-of-bounds array bugs
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/rules/javascript/no-unchecked-indexed-access
FAQ
Why is the default TypeScript behavior risky here?
By default TypeScript treats an array item as always present, even when the array is empty or the index is out of range.
Will this create a lot of new errors?
It can, and the skill says optional chaining and nullish coalescing handle most of these cleanly.
What about Array.at()?
The skill explains how Array.at() interacts with this check, so the agent can pick the right pattern.
Details
Original description by the author
Use when auditing tsconfig.json for missing safety flags, reviewing code that uses array index access in data processing pipelines, or investigating runtime undefined errors that TypeScript did not catch.
Popularity
- GitHub stars
- 75k
- Ranking position
- #2951
- License
- MIT
- Updated
- 10/31/2026
Comments
- …
More skills from this repository
frontendchecklist
75kChecks frontend code and live pages against 380+ rules for accessibility, speed, SEO and security, using a command-line tool.
frontend-checklist-global
75kAudits a frontend project against all 386 Front-End Checklist rules, and gives a specific fix for each issue found.
404-page
75kChecks that your missing-page screen offers helpful links and returns a real 404 status, to help lost visitors find their way.
about-page
75kReviews whether your site has a clear About page that explains who runs it, to build trust with visitors and search engines.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.