no-unchecked-indexed-access
하는 일
이 스킬은 TypeScript 안전 옵션인 noUncheckedIndexedAccess가 켜져 있는지 확인하고, 항목을 확인하지 않고 인덱스로 읽는 코드를 고칩니다. undefined 런타임 오류를 줄이려는 개발자를 위한 것입니다.
사용하는 경우
- ✓프로젝트의 TypeScript 설정에서 빠진 안전 옵션이 있는지 확인해 달라고 요청할 때.
- ✓TypeScript가 경고하지 않은 undefined 값 때문에 앱이 충돌할 때.
- ✓위치로 배열 항목을 읽는 데이터 처리 코드를 검토할 때.
스킬 링크
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/no-unchecked-indexed-access/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 앱이 가끔 undefined 오류로 충돌합니다. 이를 잡아내는 TypeScript 설정을 켜고, 그 설정이 지적하는 코드를 고쳐 주실 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 tsconfig.json 파일을 확인하고 옵션이 없으면 켭니다. 그다음 TypeScript가 이제 지적하는 배열 접근을 고쳐, 검사를 추가하거나 옵셔널 체이닝을 써서 항목이 없는 경우를 처리합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
자주 묻는 질문
TypeScript의 기본 동작이 왜 위험한가요?
기본적으로 TypeScript는 배열 비었거나 인덱스가 범위를 벗어나도 항목이 항상 있다고 취급합니다.
새로운 오류가 많이 생기나요?
그럴 수 있으며, 스킬은 옵셔널 체이닝과 null 병합 연산자로 대부분 깔끔하게 처리할 수 있다고 설명합니다.
Array.at()은 어떤가요?
스킬은 Array.at()이 이 검사와 어떻게 상호작용하는지 설명하여, 에이전트가 알맞은 패턴을 고르게 합니다.
상세 정보
작성자의 원본 설명
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.
인기도
- GitHub 스타
- 75k
- 순위
- #2951
- 라이선스
- MIT
- 업데이트
- 2026. 10. 31.
댓글
- …
이 저장소의 다른 스킬
frontendchecklist
75k명령줄 도구를 사용해 380개가 넘는 규칙으로 프런트엔드 코드와 실시간 페이지를 접근성, 속도, SEO, 보안 측면에서 점검합니다.
frontend-checklist-global
75kFront-End Checklist의 386개 규칙 전체로 프런트엔드 프로젝트를 감사하고, 발견한 문제마다 구체적인 해결 방법을 제시합니다.
404-page
75k없는 페이지 화면에 도움이 되는 링크가 있고 실제 404 상태 코드를 반환하는지 확인해, 길을 잃은 방문자를 돕습니다.
about-page
75k사이트를 운영하는 사람을 설명하는 명확한 소개 페이지가 있는지 검토해, 방문자와 검색 엔진의 신뢰를 높입니다.