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:
27 chars2 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:
54 chars6 lines
Again, you can replace es2018
with any other ECMAScript version that you want to target.
gistlibby LogSnag