Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TypeScript · Const

target

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.

How it works

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.

Syntax

{"compilerOptions":{"target":"es2020"}}

Parameters

NameTypeDescription
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.

Returns

Changes compiler output and default library declarations; it does not produce a runtime value.

Key points

  • Features newer than the selected target are transformed when TypeScript can provide an equivalent implementation; supported syntax may remain unchanged.
  • Use the lowest ECMAScript version supported by every deployment environment.
  • If no applicable configuration changes the default, TypeScript historically emits ES5-level JavaScript.
  • ES2015/ES6 is a practical baseline for modern browser deployments, while older environments may require a lower compatible target.

Common mistakes

  • A higher target can leave newer syntax in the output, so the runtime must support the selected ECMAScript version.
  • Changing the target also affects the default library declarations; set lib separately when the runtime APIs differ from the language target.

Example: Target emitted JavaScript for a runtime

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.

When to use it

Emit syntax compatible with a browser baseline

A web application must support older browsers.

Preserve syntax supported by the deployment runtime

A Node.js service runs on a known JavaScript runtime.

Standardize the project’s emitted JavaScript level

A large project needs consistent output across packages.

  • lib
  • module
  • useDefineForClassFields
  • downlevelIteration
  • tsconfig.json

Source: TSConfig Reference - Docs on every TSConfig option - TypeScript. Checked 2026-10-15.