Why TypeScript

The Concrete Wins, Not Just the Hype

Why TypeScript

TypeScript adds friction up front and pays it back many times over. The wins are bug prevention, editor support, and refactor safety — at a real cost.

4 min read Level 1/5 #typescript#why#motivation
What you'll learn
  • Recognize the practical wins
  • Understand the real cost
  • Decide when to opt in

TypeScript isn’t free — it adds syntax, a build step, and a learning curve. Why do millions of developers use it anyway?

1. Bugs Caught Before Run

function send(user: { email: string }) {
  fetch(`/api/send?to=${user.email.toLowerCase()}`);
}

send({ name: "Ada" });
//   ~~~~~~~~~~~~~~~
// Argument of type '{ name: string; }' is not assignable to
// parameter of type '{ email: string; }'.

In JavaScript, this would have shipped to production — and crashed with “cannot read properties of undefined” the moment a user clicked Send.

2. Autocomplete That Knows Your Code

const user = { name: "Ada", email: "ada@x.com", admin: true };
user.
//   ↑ cursor here, editor shows: name, email, admin

Free, accurate autocomplete is the single most underrated benefit. You stop guessing field names. You stop opening other files to remember what a function returns.

3. Refactor Safely

Rename a field, change a signature, move a function — the compiler walks every call site and flags what broke. Refactors that would be unsafe in JS become routine in TS.

4. Types ARE The Documentation

function paginate<T>(items: T[], pageSize: number): T[][];

You don’t need a comment explaining the function — the signature tells you what it takes and what it returns. And the docs can’t drift out of date.

5. Confidence at Scale

For projects past ~10k lines, the compile time investment is trivial compared to the time saved on bugs and refactors.

The Costs

Realistic ones:

  • Learning curve — generics, conditional types, mapped types take time
  • Compile steptsc, tsx, or a bundler
  • More keystrokes — type annotations add code
  • Types for librariesnpm install -D @types/foo for older libs

These costs shrink dramatically once you’re comfortable. The returns compound.

When To Use TS

ProjectTypeScript?
A 50-line scriptOptional
A web app you’ll maintainYes
A library others will consumeYes
A learning side projectOptional — both work
Anything more than 10k linesYes
A throwaway demoWhatever’s faster

The TypeScript ecosystem is now the default for serious JS — Node backends, React apps, Astro sites, library development.

Up Next

The primitives — string, number, boolean, etc.

Primitives →