TypeScript in 10 Minutes: From JavaScript to Type Safety
You know JavaScript. TypeScript is just JavaScript with types. Here's everything you need to start. Why bother with TypeScript? // JavaScript — no errors until runtime function greet(user) { return...

Source: DEV Community
You know JavaScript. TypeScript is just JavaScript with types. Here's everything you need to start. Why bother with TypeScript? // JavaScript — no errors until runtime function greet(user) { return `Hello, ${user.nme}`; // typo! "nme" instead of "name" } greet({ name: "Alice" }); // Returns "Hello, undefined" — silent bug! // TypeScript — catches errors at compile time function greet(user: { name: string }): string { return `Hello, ${user.nme}`; // Error: Property 'nme' does not exist } TypeScript catches bugs before you run the code. That's the whole deal. Setup in 30 seconds npm install -D typescript tsx @types/node # tsconfig.json npx tsc --init Or use TypeScript directly with Node: npx tsx my-file.ts The 8 types you'll use 90% of the time // 1. Primitives let name: string = "Alice"; let age: number = 28; let active: boolean = true; // 2. Arrays let tags: string[] = ["ts", "js"]; let scores: number[] = [95, 87, 92]; let mixed: (string | number)[] = ["a", 1, "b", 2]; // 3. Objects (i