downleveling
Rewriting modern JavaScript syntax into older, equivalent syntax so the code runs on an older target.
In more detail
Compiling optional chaining for ES5 turns a?.b into a longer check against null and undefined, and some features add helper functions to the output. Modern targets keep the syntax as written, so the output is smaller and closer to your source.
Related terms
- target (compiler option) — The compiler option that chooses which ECMAScript edition the emitted JavaScript uses, such as ES2022.
- polyfill — Code that adds a missing built-in feature to an older runtime, such as a Promise implementation for an old browser.
- emitter — The last compiler phase, which writes the JavaScript output and optional declaration files from the checked syntax tree.
Taught in
- The Compiler Pipeline: tsc, AST And Code Emission — Production TypeScript
- Custom Type Predicates: Functions Returning is Type — Production TypeScript