Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is target in tsconfig.json for?

People also ask

What does Tsconfig target do?

The target setting changes which JS features are downleveled and which are left intact. For example, an arrow function () => this will be turned into an equivalent function expression if target is ES5 or lower. Changing target also changes the default value of lib .

What is module and target in Tsconfig json?

The "target" property is used to specify the JavaScript version your TypeScript code will eventually compile into. The "module" property specifies the type of the module syntax your compiled (TS-->JS) code will use.

What should I put in Tsconfig json?

json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig. json file specifies the root files and the compiler options required to compile the project.

What TypeScript does target use?

However, right now, according to Google, 95% of global web traffic comes from web sites that support at least es2017 feature set. This means that we can target es2017 as our transpile version and be pretty confident that it will be supported.


I am quite new to Typescript. What does Target in tsconfig.json signify?

target signifies which target of JavaScript should be emitted from the given TypeScript. Examples:

target:es5

()=>null will become function(){return null} as ES5 doesn't have arrow functions.

target:es6

()=>null will become ()=>null as ES6 has arrow functions.

More

I also made a quick video on the subject 🌹.


Target changes the JavaScript version you are compiling to.

The options are available at https://www.typescriptlang.org/docs/handbook/compiler-options.html

In the spirit of trying to better understand how the target flag changes my code I compiled some test code to each of the different versions to have a better understanding of the differences.

https://github.com/aizatto/typescript-playground/tree/master/dist/test-async-main

I'm also keeping notes of what I should be targeting depending on what environment I am looking at

https://www.aizatto.com/notes/typescript