Skip to content

Enable noUncheckedIndexedAccess; guard touch-event index access#60

Merged
lwwmanning merged 1 commit intomainfrom
claude/no-unchecked-indexed-access
May 4, 2026
Merged

Enable noUncheckedIndexedAccess; guard touch-event index access#60
lwwmanning merged 1 commit intomainfrom
claude/no-unchecked-indexed-access

Conversation

@lwwmanning
Copy link
Copy Markdown
Contributor

Summary

Turns on TypeScript's noUncheckedIndexedAccess in tsconfig.json. Under this flag, every array/record index access has type T | undefined, surfacing latent unsafe-index bugs across the codebase.

The whole repo turns out to need only two call-site fixes, both the same pattern: e.touches[0] inside a touchmove handler. The browser spec doesn't strictly guarantee touches is non-empty during touchmove (some implementations fire the event with an empty list at the boundary of a touch ending), so the safest fix is to capture the touch into a local and early-return when it's undefined:

- const touchX = e.touches[0].clientX;
- const touchY = e.touches[0].clientY;
+ const touch = e.touches[0];
+ if (!touch) return;
+ const touchX = touch.clientX;
+ const touchY = touch.clientY;

Applied identically in src/components/hero/index.tsx and src/components/hero-404/index.tsx.

The velite content collection (#site/content) was the call surface I expected to be most affected, but the velite-generated types already model collection access safely, so getAllSlugs / getPostBySlug need no changes.

Test plan

  • CI green (lint, build, typecheck, verify, audit, dependency-review)
  • Vercel preview: drag the hero on the homepage with a touch device (or DevTools touch emulation) — model still rotates as expected
  • Vercel preview: same on /404 (the hero-404 variant uses the same touch handler)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Will Manning <will@willmanning.io>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vortex Ready Ready Preview, Comment May 4, 2026 6:51pm

Request Review

@lwwmanning lwwmanning merged commit 4b937da into main May 4, 2026
5 checks passed
@lwwmanning lwwmanning deleted the claude/no-unchecked-indexed-access branch May 4, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant