What is the target option in tsconfig.json

· Category: TypeScript

Short answer

The target option specifies the ECMAScript target version for compiled output, controlling which syntax features TypeScript downlevels and which built-in APIs are available for type checking.

How it works

Setting target to ES5 causes TypeScript to rewrite arrow functions, classes, and async/await into ES5-compatible code. Setting it to ES2020 preserves modern syntax and assumes the runtime supports it. The lib option separately controls which type definitions for built-in APIs are included.

Example

{
  "compilerOptions": {
    "target": "ES2020",
    "lib": ["ES2020", "DOM"]
  }
}

Why it matters

Choosing the right target balances runtime compatibility with output size and performance. Modern Node.js and evergreen browsers support ES2020 and higher, reducing the need for downleveling.