Emit syntax compatible with a browser baseline
A web application must support older browsers.
TypeScript · Const
The target compiler option selects the ECMAScript version for emitted JavaScript and compatible library declarations. Choose the lowest runtime level your supported environments can execute.
The target compiler option selects the JavaScript language level TypeScript emits. TypeScript transforms features newer than that level into compatible output where possible and includes matching library declarations; choose the lowest ECMAScript version supported by your deployment environments.
{"compilerOptions":{"target":"es2020"}}| Name | Type | Description |
|---|---|---|
target | `es3` | `es5` | `es6`/`es2015` | `es2016` | `es2017` | `es2018` | `es2019` | `es2020` | `es2021` | `es2022` | `es2023` | `es2024` | `es2025` | `esnext` | The ECMAScript version used for emitted JavaScript and compatible library declarations. Current documented values include es3, es5, es6/es2015, es2016 through es2025, and esnext. |
Changes compiler output and default library declarations; it does not produce a runtime value.
lib separately when the runtime APIs differ from the language target.const greet = (name: string): string => `Hello, ${name}`;
console.log(greet("TypeScript"));Compile this file with a selected target to control the JavaScript syntax TypeScript emits.
A web application must support older browsers.
A Node.js service runs on a known JavaScript runtime.
A large project needs consistent output across packages.
libmoduleuseDefineForClassFieldsdownlevelIterationtsconfig.json