TechnicalCollectible prompt

Add TypeScript types to loose code without changing it

Type untyped or any-heavy code from the edges in, so mistakes surface early and behavior stays the same.

Claude CodeCursorCodex

Curated by Nvoka

Nvoka wordmark logo
Nvoka wordmark logoTechnical

Add TypeScript types to loose code without changing it

Act as a senior TypeScript engineer. Parts of my {{tech_stack}} project are loosely typed: plain JavaScript files, any everywhere, or types that don't match the real data. Start with {{page_or_feature}}. Add real types without changing what the code does. 1. Survey first: count the any types, untyped files and type assertions in this area, and list where data enters the app: API responses, database queries, form inputs, URL parameters, local storage and third-party libraries. 2. Type from the edges in: - Database types generated from the schema with the project's tooling, never written by hand - API and form data validated at runtime with the schema library already in use (or Zod if there's none, after asking me), with types inferred from those schemas - Shared domain types, such as a booking, an order or a profile, defined once and reused - Then component props, hook return values and function parameters 3. Make the types honest: fields that can be missing are optional and handled; data you haven't checked is unknown until narrowed; real states such as loading, error and success are a union, not several booleans. 4. Rules: no behavior changes. When a type exposes a real bug, stop and list it for me rather than fixing it in the same step. No any, no non-null assertions on data that can be missing, no ts-ignore. Small commits, one area each, with typecheck, tests and build passing after every one. 5. Turn on stricter compiler settings gradually, one flag at a time, only once the code passes. Finish with before and after counts, the bugs the types uncovered, and the next area to type.
Technicalnvoka.com/library/nvoka-add-typescript-types-to-loose-code-safelyScan to open
Technical

Add TypeScript types to loose code without changing it

Type untyped or any-heavy code from the edges in, so mistakes surface early and behavior stays the same.

Nvoka logo

Curated by Nvoka

Claude CodeCursorCodexGitHub Copilot
Add to my library

Make it yours

Fill in the blanks and change any word. Only your copy changes, never the card.

Fill in the blanks

0 of 2 filled

Your prompt

Act as a senior TypeScript engineer. Parts of my {{tech_stack}} project are loosely typed: plain JavaScript files, any everywhere, or types that don't match the real data. Start with {{page_or_feature}}. Add real types without changing what the code does. 1. Survey first: count the any types, untyped files and type assertions in this area, and list where data enters the app: API responses, database queries, form inputs, URL parameters, local storage and third-party libraries. 2. Type from the edges in: - Database types generated from the schema with the project's tooling, never written by hand - API and form data validated at runtime with the schema library already in use (or Zod if there's none, after asking me), with types inferred from those schemas - Shared domain types, such as a booking, an order or a profile, defined once and reused - Then component props, hook return values and function parameters 3. Make the types honest: fields that can be missing are optional and handled; data you haven't checked is unknown until narrowed; real states such as loading, error and success are a union, not several booleans. 4. Rules: no behavior changes. When a type exposes a real bug, stop and list it for me rather than fixing it in the same step. No any, no non-null assertions on data that can be missing, no ts-ignore. Small commits, one area each, with typecheck, tests and build passing after every one. 5. Turn on stricter compiler settings gradually, one flag at a time, only once the code passes. Finish with before and after counts, the bugs the types uncovered, and the next area to type.
See all