StoicBuilder

HandbookI the LudusTypeScript types

Ithe Ludus, Read code

TypeScript types

1 min readUpdated 28 November

In plain words

TypeScript lets the code say what shape each value should have, so mistakes like a missing field get caught before the app runs.

Where you see it

Files ending in .ts or .tsx, and words after a colon, like price: number. When a Vercel build fails with "Type error: Property 'email' does not exist on type 'Member'", TypeScript caught a mismatch before it shipped.

src/types.tsbrowser
type Member = { id: string; name: string; role: "admin" | "moderator" | "member"; bio?: string; // the ? means optional}; const ana: Member = { id: "m1", name: "Ana", role: "owner" }; // error
The type lists the allowed roles, so "owner" is flagged before anyone runs the app.

What goes wrong

  1. Silencing errors with any

    any switches checking off for that value. When the agent adds as any to get a build through, the bug is still there, only hidden.

    const member = data as any;
  2. Types that don't match the database

    The type says bio is always a string, but Supabase returns null when that field is empty. Generate types from your schema so the two stay in step.

  3. Trusting types for data from outside

    Types are checked while the app is built, not while it runs. A form or an API can still send anything, so outside data needs checking at runtime too.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Fix TypeScript errors by correcting the types or the code, never with any, as any or @ts-ignore. If my Supabase table types are hand-written, generate them from the schema instead, and say which of the errors were real bugs.

Quick check

Sign in to earn +10 XP for it

Your Vercel build fails with a type error, and the agent's fix adds as any. What's true?

Got a prompt that touches TypeScript types?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.