emitter
The last compiler phase, which writes the JavaScript output and optional declaration files from the checked syntax tree.
In more detail
Emitting removes type annotations and, for older targets, rewrites modern syntax into older equivalents. The emitted JavaScript is what actually runs. Emit happens even when there are type errors unless noEmitOnError or noEmit is set.
Related terms
- compiler pipeline — The ordered stages the TypeScript compiler runs: scan and parse into a syntax tree, bind names, check types, then emit JavaScript.
- type erasure — The removal of all TypeScript types when code is compiled, so none of them exist while the JavaScript runs.
- noEmitOnError — The compiler option that stops tsc from writing any JavaScript if the project has type errors.
- declaration file — A file ending in .d.ts that contains only type information describing JavaScript that exists elsewhere, with no runnable code.
Taught in
- Why TypeScript: Contracts, Erased Types And Soundness — Production TypeScript
- The Compiler Pipeline: tsc, AST And Code Emission — Production TypeScript
- tsconfig.json: target, lib, strict And NodeNext — Production TypeScript
- Verify Your Environment: Running tsc And Bun TypeScript — Production TypeScript
- Why Generics: Functions, Identities And Type Variables — Production TypeScript
- ECMAScript Modules, CJS Interop And verbatimModuleSyntax — Production TypeScript