TypeScript is a programming language made by Microsoft that adds types to JavaScript. You describe what shape your data should have, for example that a price is a number and an email is text, and a checker warns you before the code runs whenever something does not fit.
How TypeScript checks and then disappears
You write files ending in .ts or .tsx. Annotations such as function total(price: number, qty: number): number tell the compiler what goes in and what comes out. The TypeScript compiler (tsc) reads the whole project and reports mismatches: passing text where a number is expected, misspelling a property name, or forgetting that a value might be missing.
Browsers do not run TypeScript. Before shipping, the types are stripped out and plain JavaScript remains. Build tools such as Vite do that stripping very quickly and usually leave the full type check to the editor or a separate command. So types cost nothing at runtime, and they also do not protect you at runtime: data arriving from a form or an outside API can still be wrong, and needs validating.
An example: a typo caught before launch
An online shop's order record has a field called shippingAddress. A developer writes order.shipingAddress in the receipt email code. In plain JavaScript that reads as undefined and customers get receipts with a blank address. In TypeScript the editor underlines it immediately with "Property does not exist", and the mistake never ships.
Why typed code matters when you hand a site over
If you never touch code, TypeScript is invisible to you and your visitors. It matters when you hire a developer or export a project to maintain later: typed code is easier for a new person to understand and safer to change, because the checker flags every place affected by an edit. Many modern starters for React default to it. We.Inc generates its sites in React, Vite, TypeScript and Tailwind CSS, so exported code arrives already typed.
Common TypeScript mistakes
- Using
anyeverywhere. It switches checking off for that value, which removes the point of the language. - Treating types as validation. A type says what you expect, not what a stranger's request actually contains.
- Ignoring errors because the build still works. Many build setups strip types without checking them, so broken code can ship unless the check runs too.
- Writing elaborate types for simple code. Clear, plain types help more than clever ones.
Related terms
- JavaScript: what TypeScript compiles to.
- Vite: a build tool that strips types during development.
- npm: where TypeScript and type packages are installed from.
- Node.js: runs the TypeScript compiler.