Overview
Use TypeScript for any code that several people will change or that will outlive its first quarter; use plain JavaScript for throwaway scripts and small embeds. The usual objection, a mandatory build step, has weakened. Node.js 22.18+ and 23.6+ strip TypeScript types by default (stable in 24.12+ and 25.2+), and TypeScript 7.0 (2026-07-08) is a native compiler about 10 times faster than 6.0. Adopt 7.0 in stages: it ships without the programmatic compiler API (planned for 7.1), so typescript-eslint and the type-checkers behind Vue, Svelte, and Astro files cannot use it yet.
Comparison
| Dimension | TypeScript | JavaScript |
|---|---|---|
| Refactoring | Compiler lists every broken call site | Search and tests |
| Contracts | Shared types across frontend and backend (Zod, Prisma, tRPC) | Runtime validation only |
| Library types | Built in or DefinitelyTyped | Often present via JSDoc or .d.ts; editor support is weaker |
| Run without a build | Node strips types; no enum, runtime namespace, or parameter properties; tsconfig.json is ignored | Always |
| Cost | Type check step in CI; generics and narrowing to learn | None |
Pick TypeScript when
Pick TypeScript for products, libraries, and shared code.
- Start with
strict: true. See typescript-tsconfig and typescript-strict-mode. - Set
erasableSyntaxOnly: trueif you run files directly with Node or want output that needs no transform. - Libraries ship
.d.tsfiles and both ESM and CJS if consumers need both. - Use
unknownand narrowing, not blanketany, when migrating.
Pick JavaScript when
Pick plain JavaScript when types would cost more than they return.
- One-off scripts and glue under a few hundred lines. Add
// @ts-checkplus JSDoc for editor hints without a compiler. - Notebooks and browser snippets with no build pipeline.
- Prototypes with a stated deletion date; if one survives, convert it.
Migrate to TypeScript
Convert gradually, leaf modules first.
- Add
tsconfig.jsonwithallowJs: true; rename files from.jsto.tsone at a time. - Start lenient, then enable
noImplicitAnyandstrictNullChecks. - Use
// @ts-expect-errorwith a reason, not// @ts-ignore, so stale suppressions fail the build.
FAQ
Is TypeScript worth it for a small project?
Use TypeScript once several people will change the code or it will outlive its first quarter. For one-off scripts under a few hundred lines, use plain JavaScript with // @ts-check and JSDoc.
Can Node.js run TypeScript without a build step?
Yes; Node.js 22.18+ and 23.6+ strip TypeScript types by default, stable in 24.12+ and 25.2+. It ignores tsconfig.json and rejects enums, runtime namespaces, and parameter properties, so set erasableSyntaxOnly: true.
Should I upgrade to TypeScript 7 now?
Adopt 7.0 in stages, since it ships without the programmatic compiler API (planned for 7.1). Until then typescript-eslint and the type-checkers behind Vue, Svelte, and Astro files cannot use it.
How do I migrate a JavaScript codebase to TypeScript?
Add tsconfig.json with allowJs: true and rename leaf modules from .js to .ts one at a time. Start lenient, then enable noImplicitAny and strictNullChecks.