How the Compiler Works

How the Compiler Works Under the Hood

tsc is a pipeline of five phases, each consuming the previous one's output. In TypeScript 6.0 each phase is one file in src/compiler/; the Go port keeps the design as packages under internal/.

The TypeScript compiler pipeline
The TypeScript compiler pipeline

--extendedDiagnostics reports the time spent in each phase:

Timing the phases with TypeScript 7.0Shell
$ npx tsc --extendedDiagnostics --outDir dist cart.ts | grep -E "Files|Memory used|time"
Files:              83
Memory used:    65514K
Parse time:     0.033s
Bind time:      0.011s
Check time:     0.238s
Emit time:      0.002s
Total time:     0.286s

The 11-line cart.ts pulls in 82 standard library files (lib.es2025.d.ts, lib.dom.d.ts and more), and checking dominates. TypeScript 6.0 needed 0.98 s and 149 MB for the same job. Because checking is the costly phase, TypeScript 7.0 spreads files across parallel checker workers.