Tooling#
TypeScript piggybacks on the JavaScript ecosystem and adds a compiler plus a few type-aware tools.
Compiler#
TypeScript, the official compiler (
tsc).
$ npm install -D typescript
$ npx tsc --init
$ npx tsc
$ npx tsc --noEmit
$ npx tsc -w
Direct Runners#
For dev loops without a build step.
tsx, run TS files directly with esbuild under the hood.
ts-node, the long-time default.
Bun, runs
.tsnatively.Deno, TS-native runtime.
$ npx tsx src/main.ts
$ bun run src/main.ts
Bundlers#
Most TS code runs through a bundler in production.
esbuild, fast, minimal config.
Vite, dev server + Rollup-based builds.
tsup, esbuild wrapper for libraries.
Rollup, library bundler.
webpack, still common in legacy apps.
Note that most bundlers transpile TS by stripping types; they don’t type-check.
Run tsc --noEmit separately in CI.
Linters#
typescript-eslint, ESLint plugin with TS-aware rules.
Biome, Rust-based linter + formatter, faster alternative.
$ npm install -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
$ npx eslint .
Formatter#
$ npx prettier --write .
Testing#
Vitest, TS-native, fast.
Jest, with
ts-jestor@swc/jest.Playwright, end-to-end with first-class TS support.
$ npx vitest
Debugging#
VS Code, launch
ts-node/tsxwith source-map support.node --inspect-brk -r tsx/esm src/main.ts, attach Chrome DevTools.Source maps (
"sourceMap": trueintsconfig) make stack traces point at original.tslines.
Documentation#
TypeDoc, generates HTML docs from TS source.
$ npx typedoc src/index.ts
Editor Support#
The TypeScript Language Server is bundled with
typescriptand used by every major editor out of the box.tsserver, the underlying server; speaks the LSP via VS Code’s
typescript-language-features.
Useful tsconfig Flags#
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"strict": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"skipLibCheck": true,
"sourceMap": true,
"outDir": "dist"
}
}