JavaScript with a type system. The de-facto choice for serious frontend and backend JS work — catches bugs at compile time without leaving the JS ecosystem.
← Back to Client Sidetype Customer = { name: string; age: number; active?: boolean; // optional }; function greet(c: Customer): string { return `Hello, ${c.name}!`; } // Discriminated unions — pattern matching without runtime cost type Result<T> = | { ok: true; value: T } | { ok: false; error: string }; function handle<T>(r: Result<T>) { if (r.ok) use(r.value); else log(r.error); }
string, number, boolean, null, undefined, symbol, bigint.A | B) and intersections (A & B)."GET" | "POST".Turn on "strict": true in tsconfig.json for the safest mode. Includes strictNullChecks (no surprise nulls), noImplicitAny, and more.
TypeScript figures out most types automatically. Inside an if (typeof x === "string") block, x is treated as a string. This narrowing makes typed code feel natural to write.
| Tool | Purpose |
|---|---|
| tsc | The reference compiler from Microsoft. |
| esbuild / swc | Ultra-fast TS-to-JS transformers (skip type checking). |
| ts-node / tsx | Run TypeScript directly in Node without a build step. |
| Zod / Valibot / io-ts | Runtime validation that infers TS types. |
| Type definitions | @types/* packages from DefinitelyTyped. |
React, Vue, Angular, Svelte — all TypeScript-first today.
NestJS, Fastify, Hono, tRPC — type-safe end-to-end.
Publish strong types; consumers get IntelliSense for free.
Same types on client and server (e.g., tRPC, Remix).