Menu

1 / 2

TypeScript's noUncheckedIndexedAccess: Turn It On, See What Breaks

DEV Community·Gabriel Anhaia·6 months ago
#LoQgup9w
#typescript#programming#undefined#first#const
Reading 0:00
15s threshold

Book: TypeScript Essentials — From Working Developer to Confident TS, Across Node, Bun, Deno, and the Browser

Also by me: The TypeScript Library — the 5-book collection

My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools

Me: xgabriel.com | GitHub

A team I talked to had a service that crashed roughly twice

a month with Cannot read properties of undefined . Always the

same shape. Some array of users came back from a query, the

caller wrote users[0].email , and on the day the query

returned zero rows the whole pod fell over. They had strict

on. They had ESLint. They had unit tests for the function. The

test fixture always had a user.

The flag that catches this bug was added to TypeScript in 4.1,

in late 2020 ( release notes ).

Most codebases still ship with it off. The reason is the cleanup

is real and the migration looks scary at first.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.