Technology

Why I Hate JavaScript

17 Sep 2026

and TypeScript doesn't really help

I've been writing software professionally for a long time, in a lot of languages. None of them make me as reliably grumpy as JavaScript — and, despite what its fans will tell you, TypeScript only papers over the problem. It doesn't fix it.

This isn't a "JS bad, my favorite language good" rant for its own sake. It's an attempt to explain specifically what's wrong, because I think the specific failure mode gets glossed over a lot: TypeScript's types don't exist once your program is actually running. Everything else people complain about in JavaScript — and there's a lot — is downstream of the same underlying design: JavaScript was never built to be a typed language, and TypeScript is a very good compile-time costume on top of a runtime that doesn't know or care what a type is.

The bug that started this post: dates that aren't dates

Here's a scenario every TypeScript developer has hit. You define a type for data coming back from an API:

interface Invoice {
  id: string;
  amount: number;
  issuedAt: Date;
}

You call your REST endpoint, parse the JSON, and get back something typed as Invoice:

const res = await fetch("/api/invoices/42");
const invoice = (await res.json()) as Invoice;

console.log(invoice.issuedAt.getFullYear());
// TypeError: invoice.issuedAt.getFullYear is not a function

That crashes. Not because your type annotation is wrong in spirit — the server really is describing an invoice with an issue date — but because JSON.parse (which is what res.json() calls under the hood) has no concept of Date. JSON doesn't have a date type. It has strings, numbers, booleans, objects, arrays, and null. So issuedAt comes back as the string "2026-09-14T12:00:00Z", and the as Invoice cast just... tells the compiler to trust you. It does zero runtime checking. It's not a validation, it's a lie you tell the type checker, and the type checker believes you because that's literally all it can do — it doesn't exist anymore by the time this code runs.

This is the crux of it: TypeScript types are erased. Compile invoice.ts to JS and look at the output — every interface, every type annotation, every generic parameter is gone. There's no Invoice type at runtime for anything to check against. TypeScript is a linter with excellent taste that happens to also compile down to JavaScript; it is not a type system in the sense that Java, C#, Rust, or Dart have type systems, where a type is a real, checked thing at runtime (instanceof, sealed class hierarchies, pattern matching, whatever). In TypeScript, as Invoice and as unknown as Invoice compile to the same nothing. The compiler will happily let you assert any shape onto any value, because an assertion is a promise to the compiler, not a check against reality.

The honest fix requires a second thing: a runtime validator (Zod, io-ts, ArkType, hand-rolled if statements) that actually inspects the JSON and either converts issuedAt into a real Date or throws. Which means every non-trivial TypeScript codebase that talks to a network — i.e., basically all of them — needs two type systems layered on top of each other: the compile-time one for editor tooling and the runtime one for actual safety, kept in sync by hand or by a code generator, because the language gives you no way to unify them.

"Once it's running, there are no more types"

That's really the sentence I want this post to leave you with. TypeScript is a build step. It's tsc (or esbuild, or swc, or Babel) stripping your annotations and shipping plain JavaScript to a runtime — a browser's JS engine, or Node, or Bun — that has exactly the same dynamic, untyped semantics it's always had. Nothing about "compiling" TypeScript makes the resulting program more type-safe while it runs; it only makes the authoring experience nicer, assuming nobody on the team reaches for any, as, !, or a // @ts-ignore under deadline pressure (they will).

Some concrete consequences of that:

  • any is viral and everywhere. One untyped third-party library, one JSON.parse, one as any under pressure, and the "any-ness" spreads through everything that touches it, silently, because TypeScript's job is to get out of your way, not to stop you.
  • Non-null assertions (!) are just a way to tell the compiler to shut up. user!.profile!.avatar!.url compiles fine and blows up at 2am when one of those actually is null.
  • Structural typing means "looks right" is good enough. Two completely unrelated types with the same shape are interchangeable. It's flexible, and it's also how you accidentally pass a LoginRequest where a RegisterRequest was expected and the compiler shrugs, because to TypeScript they're the same thing if the fields line up.
  • strict mode is opt-in. A huge amount of the safety people credit to "using TypeScript" actually comes from turning on strictNullChecks and friends in tsconfig.json — which plenty of real projects don't, or don't fully, because it's painful to retrofit.

None of this is a gotcha about sloppy code. It's what you'd expect from a type system that is, by design, not there anymore once the program starts.

The rest of the greatest hits

Even setting the type-erasure problem aside, JavaScript itself keeps finding new ways to be JavaScript, and TypeScript inherits all of it because TypeScript is JavaScript with an optional compile step:

  • One number type. Every number is a 64-bit float. 0.1 + 0.2 !== 0.3. Integers above 2^53 silently lose precision unless you remember BigInt exists and thread it through your whole program by hand.
  • Two ways to mean "nothing." null and undefined both exist, mean subtly different things depending on who you ask, and TypeScript spends a whole category of complexity (strictNullChecks, ??, ?.) just taming the fact that the language has two null values instead of one sane option type.
  • == still exists. Yes, you should always use ===. Yes, someone on your team, or some dependency, or some old code you inherited, uses == anyway, and "" == 0 is true because JavaScript decided coercion should be a personality trait.
  • Prototypal inheritance wearing a class costume. ES6 class syntax is sugar over prototype chains that behave nothing like the classes you know from actually class-based languages — this binding is dynamic and context-dependent, and "which this am I in" is a genuine, recurring source of bugs that arrow functions only mostly fix.
  • Everything is mutable by default, objects and arrays alike, with no language-level concept of value types or built-in immutability — you either discipline yourself into Object.freeze/spread-everywhere, or reach for a library, because the language won't help you.
  • Async footguns. An unhandled promise rejection used to just vanish silently; now it (sometimes) crashes the process, depending on the runtime and version. forEach doesn't await anything inside it and fails silently if you try. async functions that forget to await are a top contributor to "why did this run out of order."
  • The ecosystem is enormous and shallow. npm install for a single toy project pulls in hundreds of transitive dependencies of wildly varying quality and maintenance status — a supply-chain surface area that's hard to reason about, and this is orthogonal to typing but it's very much part of "why JavaScript development is exhausting."
  • Tooling complexity as a tax, not a choice. To get a "modern" and reasonably safe JS/TS setup you're assembling tsc (or swc/esbuild), a bundler, a linter, a formatter, and their configs, and keeping them all compatible across upgrades — none of which is core to the language, all of which is required to make the language tolerable.

TypeScript genuinely helps with a lot of this at the editor level — autocomplete, refactors, catching typos, documenting intent. I don't want to undersell that; it's a real improvement over plain JS for a team of any size. But it's improving the authoring experience of a language whose runtime semantics haven't changed, and several of the sharpest edges above (coercion, mutability, this, numeric precision, the null/undefined split) are runtime behaviors TypeScript has no power to fix even in principle, because fixing them would mean changing what the JavaScript engine actually does.

What I'd use instead

If you're building something for the web and you want types that are still true after your program has been running for six hours, you need a language where types aren't a lint pass — they're part of what the runtime actually is.

If you like TypeScript's syntax and want to stay in that neighborhood: Flutter (Dart). Dart's type system is sound and enforced by the Dart VM/AOT-compiled runtime, not stripped away at build time. Null safety is a real, checked guarantee, not a tsconfig flag you hope everyone left on. And Flutter gets you a single codebase that targets web, mobile, and desktop with one real UI framework, instead of stitching together a different story for each platform.

If you're comfortable with — or willing to learn — Rust: Rust compiled to WebAssembly, with a framework like Leptos or Dioxus. This is the sharpest possible contrast to the Invoice example above. In Rust, using serde, the equivalent deserialization looks like:

#[derive(serde::Deserialize)]
struct Invoice {
    id: String,
    amount: f64,
    issued_at: chrono::DateTime<chrono::Utc>,
}

let invoice: Invoice = serde_json::from_str(&body)?;

If issued_at in the JSON isn't a string serde's chrono integration can actually parse as a timestamp, this doesn't silently hand you a string wearing a DateTime costume — serde_json::from_str returns an Err, right there, at the parse boundary, before the bad data ever gets anywhere near the rest of your program. The type isn't a promise to the compiler that evaporates after tsc runs; it's a guarantee the runtime itself enforces, backed by a borrow checker that also rules out whole categories of bugs TypeScript can't touch (data races, use-after-free, mutating something two places think they own exclusively) — and it's the same language and the same guarantees whether that code is running server-side or compiled to WASM in the browser.

Neither of these is "easier" than reaching for React and TypeScript today — the ecosystems are smaller, the learning curve for Rust in particular is real, and hiring is harder. But "easier to start" and "actually type-safe" are different axes, and JavaScript (TypeScript included) keeps choosing the first one. If you've ever debugged a .getFullYear is not a function at an hour you'd rather not be awake for, you already know which one I think matters more.

Comments

No comments yet.

Log in to leave a comment.