Running tsc in Parallel with Bundling
What you'll learn: How to set up a development workflow where TypeScript type-checking runs alongside your bundler's dev server to catch errors without sacrificing build speed.
The Problem
Modern bundlers like Vite, esbuild, and Webpack with swc are incredibly fast because they skip TypeScript's type-checking—they just strip types and transpile. You get instant hot-reload, but you lose compile-time error detection during development.
Running tsc before every bundler rebuild would be too slow. The solution? Run them in parallel.
The Parallel Workflow Pattern
Think of it like having two monitors: one showing your app running (the bundler's dev server), and another showing TypeScript's complaints (the type-checker). Both update independently, giving you comprehensive feedback.
Typical setup:
- Terminal 1: Your bundler runs in watch mode (e.g.,
vite devorwebpack serve) - Terminal 2:
tsc --noEmit --watchruns continuously, type-checking without generating files
The bundler handles the actual build and hot-reload. TypeScript catches type errors in real-time.
How It Works in Practice
Most developers use npm-run-all or similar tools to orchestrate both processes:
{
"scripts": {
"dev": "npm-run-all --parallel dev:*",
"dev:bundler": "vite",
"dev:types": "tsc --noEmit --watch"
}
}
Running npm run dev launches both processes simultaneously. You get fast rebuilds from the bundler and comprehensive type safety from tsc.
Why This Matters
Bundlers optimize for speed; TypeScript optimizes for correctness. Running them in parallel gives you both—immediate feedback in your browser and type errors in your terminal without waiting for slower type-checking to complete.
Key Takeaway: Running tsc --noEmit --watch in parallel with your bundler's dev server combines the speed of modern build tools with TypeScript's full type-checking power, ensuring you catch errors during development without slowing down your workflow.