target (compiler option)
The compiler option that chooses which ECMAScript edition the emitted JavaScript uses, such as ES2022.
In more detail
Newer syntax is kept as is when the target supports it; for an older target, tsc rewrites it into older code, sometimes with helper functions. TypeScript 6.0 deprecated the ES5 target and defaults to the newest edition, currently ES2025. Pick the oldest edition your runtime supports.
Example
tsc --target ES2022 app.tsRelated terms
- ECMAScript — The official standard that defines the JavaScript language, updated every year by a committee of the Ecma International standards body.
- lib (compiler option) — The compiler option that lists which built-in type declarations are available, such as ES2022 features or browser DOM types.
- downleveling — Rewriting modern JavaScript syntax into older, equivalent syntax so the code runs on an older target.
- polyfill — Code that adds a missing built-in feature to an older runtime, such as a Promise implementation for an old browser.
Taught in
- The Compiler Pipeline: tsc, AST And Code Emission — Production TypeScript
- Declaration Files, Ambient Namespaces And Module Augmentation — Production TypeScript