# Enable noUncheckedIndexedAccess for Safer Array Index Access

Enables TypeScript's `noUncheckedIndexedAccess` flag to catch out-of-bounds array errors at compile time, ensuring explicit checks for array index access and preventing runtime undefined errors.

**Canonical URL:** https://skillshunter.net/skills/github-thedaviddias-front-end-checklist-skills-no-unchecked-indexed-access-9811f19e5462

**JSON URL:** https://skillshunter.net/api/public/v1/skills/github-thedaviddias-front-end-checklist-skills-no-unchecked-indexed-access-9811f19e5462

**Markdown URL:** https://skillshunter.net/skills/github-thedaviddias-front-end-checklist-skills-no-unchecked-indexed-access-9811f19e5462.md

**Instructions download URL:** https://skillshunter.net/skills/github-thedaviddias-front-end-checklist-skills-no-unchecked-indexed-access-9811f19e5462/download

**Category:** Software & Development

**Source URL:** https://github.com/thedaviddias/Front-End-Checklist/blob/e8d14d049010e2ce25afcd5e8609dfcbbe63e47e/skills/no-unchecked-indexed-access/SKILL.md

**Source commit:** e8d14d049010e2ce25afcd5e8609dfcbbe63e47e

**Listing approved at:** 2026-11-24

**Created at:** 2026-11-22T17:11:37.000000Z

**Updated at:** 2026-11-24T07:12:05.000000Z

## Catalog information

The following descriptions are catalog information. Listing approval does not mean the skill has been tested or is safe for every environment.

### Editor's note

Before enabling noUncheckedIndexedAccess, ensure that the project's tsconfig.json is configured to support it. Developers must update any array index accesses to include explicit undefined checks or use optional chaining to avoid type errors.

### When to use it

- Auditing tsconfig.json for missing safety flags
- Reviewing code that uses array index access in data processing pipelines
- Investigating runtime undefined errors that TypeScript did not catch

## Skill instructions

---
name: no-unchecked-indexed-access
description: "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."
metadata:
  category: javascript
  priority: medium
  difficulty: intermediate
  estimatedTime: "15"
  source: frontendchecklist.io
  url: https://frontendchecklist.io/rules/javascript/no-unchecked-indexed-access
---

# 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

