freecoding.school100% FREE · NO SIGNUP
API ArcadeISSUE #18 of 23

typescript · adding types to js

ApiaVSLegacy Larry
Apia saysTypeScript adds static types to JavaScript, catching bugs before the code runs.

TypeScript is a superset of JS that adds optional type annotations (let n: number, interfaces, generics). A compiler checks types and strips them to plain JS. It catches typos, wrong shapes, and bad refactors at author time, and powers rich editor autocomplete. The cost is a build step and learning the type system — worth it on any non-trivial codebase.

Power-ups you unlock

Legacy Larry attacks — common mistakes

Boss battleAnnotate a function’s parameters and return type in your head; note the bug TS would catch.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>// TypeScript
function add(a: number, b: number): number {
  return a + b;
}
add(2, '3'); // ❌ compile error caught before running</pre></body></html>
▶ Open the interactive comic issue
‹ Webauthn · Passkeys · BiometricsLinting · Eslint · Prettier ›