TypeScript Compiler Options
target — TypeScript compiler option
Selects the JavaScript language level for emission and influences the default library declarations. Lower targets rewrite supported syntax; they do not supply missing runtime APIs or guarantee compatibility with an old engine. ESNext changes meaning with compiler releases. In 5.8.3 ES3 is removed despite appearing in the extracted enum metadata. Default: ES5 when omitted in this baseline with CommonJS. Create the named files in a clean local project and run tsc -p tsconfig.json. Expected emitted files: dist/example.js. Run node dist/example.js; expected stdout: '6'. Tested with TypeScript 5.8.3 and Node.js 22.16.0; local project example, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "target": "ES2022" }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| target | ECMAScript target string | Set in compilerOptions; ES5 when omitted in this baseline with CommonJS. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "outDir": "dist" }, "files": [ "example.ts" ]}// File: example.tsconst twice = (n: number) => n * 2;console.log(twice(3));