Skip to content

The tsconfig file

Course: Typescript - chapter 5

The tsconfig file has a bunch of options that you can change to change the compilation process.

Some of these include

The **target** option in a **tsconfig.json** file specifies the ECMAScript target version to which the TypeScript compiler will compile the TypeScript code.

To try it out, try compiling the following code for target being ES5 and es2020

const greet = (name: string) => `Hello, ${name}!`;
Output for ES5
"use strict";
var greet = function (name) { return "Hello, ".concat(name, "!"); };
Output for ES2020
"use strict";
const greet = (name) => `Hello, ${name}!`;

Where should the compiler look for .ts files. Good practise is for this to be the src folder

Where should the compiler look for spit out the .js files.

Try enabling it and see the compilation errors on the following code -

const greet = (name) => `Hello, ${name}!`;

Then try disabling it

Weather or not to include comments in the final js file