What TypeScript Is and Why Use It

Harry · 14 Sep 2026 · 3 views
Advertisement
Advertisement

JavaScript with types

TypeScript is a superset of JavaScript that adds optional static types. Every valid JavaScript file is already valid TypeScript; you opt into types where they help. A separate step, the TypeScript compiler (tsc), checks those types and then emits ordinary JavaScript that runs in any browser or Node.js.

A .ts file compiled by tsc into a .js file that runs anywhere JavaScript runs

Catching bugs before runtime

JavaScript only discovers type mistakes when the code runs – often in production. TypeScript surfaces them in your editor as you type:

function total(price: number, qty: number) {
  return price * qty;
}

total(10, 5);       // 50
total("10", 5);     // Error: string is not a number

Types are erased

Types exist only at compile time. The emitted JavaScript contains no type annotations at all – there is zero runtime cost. This is why TypeScript runs anywhere JavaScript does, with the same performance.

Why teams adopt it

  • Fewer bugs: whole categories of errors become compile errors.
  • Better tooling: precise autocomplete, safe refactoring, jump-to-definition.
  • Self-documenting code: signatures state exactly what a function expects and returns.
  • Scales: large codebases stay maintainable as teams grow.

Key points

  • TypeScript is JavaScript plus optional static types.
  • The tsc compiler checks types, then emits plain JavaScript.
  • Types are erased at compile time – no runtime overhead.
  • It reduces bugs and powers strong editor tooling, especially on large projects.
Share this post:

Comments (0)

Please login or register to comment.