TypeScript Migration
Status: Active Last Updated: 2026-02-08
Overview
Complete migration of the Next.js design experiments sandbox from JavaScript (.jsx) to TypeScript (.tsx), establishing type safety across all experiments and components.
Key Components
- All experiment pages (
app/*/page.tsx) - Converted to TypeScript with proper typing - Type definitions - Added
@types/react-domand@types/chroma-jsfor third-party libraries - tsconfig.json - Configured with strict mode enabled
- Build verification - All experiments build without TypeScript errors
Implementation Details
Migration approach:
- Renamed all
.jsxfiles to.tsx - Added type annotations for:
- React component props
- Event handlers (KeyboardEvent, MouseEvent, etc.)
- State hooks (useState with explicit types)
- Ref hooks (useRef with HTMLElement types)
- Fixed all TypeScript strict mode errors
- Verified production build passes
Type patterns used:
Record<string, string>for object mapsReact.CSSPropertiesfor inline styles with CSS variablesReact.KeyboardEvent<HTMLElement>for keyboard handlersHTMLElementtype assertions for DOM manipulation- Custom types for domain objects (FontPairing, etc.)
Strategic use of any:
- Animation classes with complex dynamic properties
- DOM manipulation code that's self-contained
- Interim states to avoid massive type rewrites in experiments
Related Files
app/blend/page.tsx- TypeScript conversion with intersection observerapp/day-at-a-glance/page.tsx- Record type for checkbox stateapp/geist-pixel/page.tsx- Text scramble class with proper typesapp/spec-sheet/page.tsx- FontPairing type definitionapp/terminator/page.tsx- TextScramble class with full typingapp/youre-doing-it-wrong/page.tsx- Simple conversionapp/color-spec/page.tsx- Refactored with extracted componentstsconfig.json- TypeScript configurationpackage.json- Added type definition packages
Future Improvements
- Replace strategic
anyuses with proper interface definitions - Add stricter typing for animation classes
- Create shared type definitions for common patterns
- Add prop type interfaces for all extracted components
- Consider using Zod for runtime validation of external data
References
- TypeScript strict mode: All experiments compile without errors
- Build verification:
npm run buildpasses successfully