configure the typescript compiler to target a specific version of ecmascript in typescript

To configure the TypeScript compiler to target a specific version of ECMAScript, you can use the --target flag when running the tsc command. Here's an example command that targets ECMAScript 2018:

tsc --target es2018 app.ts
27 chars
2 lines

You can replace es2018 with any other ECMAScript version that TypeScript supports, such as es5, es6, es2015, es2016, es2017, es2019, es2020, or esnext.

Alternatively, you can set the target property in your tsconfig.json file to specify the default target for all TypeScript files in your project. Here's an example tsconfig.json file that targets ECMAScript 2018:

{
  "compilerOptions": {
    "target": "es2018"
  }
}
54 chars
6 lines

Again, you can replace es2018 with any other ECMAScript version that you want to target.

gistlibby LogSnag