JavaScript solves the problem of writing code browsers understand. That's what it does, and it does it well. But it's a loosely typed system. You can pass a number to a function that expects a name. You can misspell a variable. You can call a method that doesn't exist. JavaScript won't stop you. It runs the code, and if it crashes, it crashes in your user's browser at three in the morning.
TypeScript is the same thing, but with a layer on top that catches those errors while you're still writing.
The simple example
A function that greets a user with their name. In JavaScript you might accidentally write `user.nme` instead of `user.name`. JavaScript notices nothing. The function returns "Hello, undefined" and you don't even know it happened.
In TypeScript the editor knows `user` has the shape `{ name: string }`. The red underline appears directly under the typo, in the same second you type it, before you run a single line. You fix it in two seconds instead of finding it after a user reported that the greeting function seems broken.
That's TypeScript in a nutshell: move errors from runtime to write-time.
Types are documentation
One of the more underrated aspects of TypeScript is that type definitions function as living documentation.
A function that receives a `Product` with fields `id`, `name`, `price`, `inStock` and `category` communicates exactly what it expects without you reading comments or guessing. The editor shows it when you hover. The error message tells you what's missing if you forget a field. The code is self-documenting in a way plain JavaScript never can be.
This matters especially in teams and in projects that live a long time. Code you wrote six months ago is essentially someone else's code. TypeScript makes it readable.
Why it matters for AI assistance
There's a more immediate reason to care about TypeScript: it's one of the factors that most strongly determines the quality of AI-generated code.
When Claude Code writes TypeScript, it doesn't just see the code you're writing. It sees the types you've defined for your database tables, what props your components expect, what values your APIs return. Supabase can generate TypeScript types directly from your database schema with a single command, and after that the entire app knows the shape of every database table.
That means Claude can catch mistakes before it suggests them. It can see that you're trying to pass a string to a function that expects a number. It can autocomplete correctly based on the actual types in your project instead of guessing.
Types are the contract between different parts of your code. And in an AI-assisted codebase, they're the contract between your intention and what's actually built.
