iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

TS Intro

TypeScript is JavaScript with an opt-in static type system. You write .ts, the compiler checks the types, and it emits plain .js that runs anywhere JS runs.

Why bother

  • Catches bugs at compile time — missing properties, wrong types, typos.
  • IDE superpowers — accurate autocomplete, refactors, find-references.
  • Self-documenting — signatures show intent; any is the new "TODO".
  • Refactor with confidence — rename a field; the type checker finds every consumer.
  • Big-team friendly — types are a contract between modules.

How it relates to JavaScript

TS featureWhat happens at runtime
Type annotations (: string)Erased — gone.
Type aliases / interfacesErased.
GenericsErased.
EnumsCompile to a JS object.
ClassesCompile to JS classes.
DecoratorsCompile to function calls.

Who uses it

Most large JavaScript codebases — VS Code, Slack, Airbnb, Microsoft Office, Notion, Vercel, every modern frontend framework's docs and source. State-of-JavaScript-2024 says ~78% of professional JS devs reach for TS by default.

The TypeScript you're learning

This tutorial targets TypeScript 5.x: satisfies, the const type parameter, decorators (stage 3), using for resource disposal, faster build modes. Modern patterns first; legacy syntax flagged where you'll still see it.

Tip: The TS team's slogan is "JavaScript that scales". If your project is a single small file you'll get away with plain JS. The moment a second person touches the code, types start paying for themselves.

Example

Example
// TypeScript adds types on top of JavaScript.
const name: string = 'Ada';
const age: number = 36;
console.log(`${name} is ${age}`);
Try it Yourself »

Exercise

TypeScript is a static…

system on top of JavaScript

Test yourself

Q1. TypeScript files commonly use the extension…
Q2. At runtime, TypeScript code…
Q3. This tutorial targets…

Discussion

Loading…