JavaScript vs TypeScript
JavaScript is the dynamically-typed language every browser runs and that powers most modern web and Node.js back ends. TypeScript is JavaScript with an added static type system; it compiles to plain JavaScript and runs the same places, but catches whole classes of mistakes at build time instead of in production.
Last reviewed on 2026-04-27.
Quick Comparison
| Aspect | JavaScript | TypeScript |
|---|---|---|
| What it is | A dynamically-typed scripting language | JavaScript with optional, then increasingly strict, static types |
| Maker | Standardised by ECMA (ECMAScript) | Microsoft, open-source |
| Runs where | Browsers, Node.js, Deno, Bun, embedded engines | Compiled to JS, then anywhere JS runs |
| Errors caught at | Run time | Build time (type errors), then run time (everything else) |
| Build step | None required | Required (tsc, esbuild, swc, webpack/vite, etc.) |
| Editor support | Good | Excellent — autocomplete, refactor, jump-to-definition all stronger |
| Runtime cost | None | None (types vanish at compile) |
| Adoption | Universal | Standard for new medium and large web projects |
Key Differences
1. TypeScript is JavaScript with extras
JavaScript is the language. Anything that runs in a browser or Node is, ultimately, JavaScript.
TypeScript is a strict superset: every valid JS file is also valid TS. Adding types is incremental — you can rename a .js file to .ts, fix what the compiler complains about, and you have TypeScript.
2. When errors appear
In JavaScript, type-related bugs surface at run time. cart.totl instead of cart.total returns undefined and propagates silently until something visible breaks.
In TypeScript, the compiler catches the typo before the code ships. The earlier feedback tightens the iteration loop and shrinks the class of bugs that reach production.
3. Build step
JavaScript in many setups needs no build at all. A .js file is shippable as-is.
TypeScript needs a compile step. Modern toolchains (Vite, esbuild, swc) make it fast — usually milliseconds — but the dependency on a tool exists, and projects need to keep it healthy.
4. Editor experience
JavaScript editors do their best with inferred types and JSDoc.
TypeScript editors give precise autocomplete, refactoring (rename a function and every caller updates), and inline error reporting. For larger codebases, the productivity difference is substantial.
5. Adoption pattern
JavaScript is the default for tiny scripts, prototypes, and where adding a build step isn't worth it.
TypeScript has become the default for medium and large web projects, libraries that ship type definitions to consumers, and most new framework code (React, Vue, Angular, Svelte all support TS first-class).
6. Runtime behaviour
JavaScript performs the same way regardless of types you may have annotated mentally.
TypeScript has zero runtime cost: types are erased at compile. Performance is identical to the equivalent JS.
When to Choose Each
Choose JavaScript if:
- Tiny scripts where a build step isn't worth setting up.
- Quick prototypes that may never become production code.
- Embedding small bits of logic in a larger non-JS project where TS tooling adds friction.
Choose TypeScript if:
- Any non-trivial application or library you'll maintain over time.
- Codebases with multiple contributors — types act as enforced documentation.
- Libraries that publish typed APIs for consumers.
- Migrating from a JS codebase that's outgrown the loose-typing model.
Worked example
A small CLI written in pure JavaScript stays under 100 lines and hardly justifies a build step. The same team's production web app, three years and twenty thousand lines later, has been TypeScript for most of its history — they migrated file-by-file, fixed several real bugs the compiler turned up, and now refactor with confidence because the editor's rename actually finds every caller. Two different projects, two right answers.
Common Mistakes
- "TypeScript is a different language." It's JavaScript plus types. Knowing one means knowing most of the other.
- "TypeScript will catch all bugs." It catches type-related bugs at compile. Logic bugs, network errors, and race conditions still happen.
- "TypeScript runs slower than JS." Types are stripped at compile. The runtime is identical.
- "TS is only for big projects." The threshold has dropped. Even small libraries often ship TS now because consumers benefit from the type definitions.