Understanding tsconfig.json

Adding a tsconfig.json file is an indication of having a directory that is of a TypeScript project, and a configuration file is needed to compile the TypeScript into JavaScript. You compile the TypeScript into JavaScript by using the tsc command. Invoking it, the compiler searches for configurations loaded in tsconfig.json. You can specify compilation for a complete project (from the current directory to the parent directory) or you can specify tsc for a particular project. You can find all possible options using the following command:

tsc --help

Let's have a look at what the command does:

The tsc help command

At the time of writing, the version of TypeScript is 2.6.2 and all context would be made from the same version. If you do not have the updated version, run the following commands:
npm uninstall typescript -g
npm install typescript@latest -g

Let's now look into the sample tsconfig.json file and all options that are available:

{ 
"compilerOptions":{
"target":"es6",
"moduleResolution":"node",
"module":"commonjs",
"declaration":false,
"noLib":false,
"emitDecoratorMetadata":true,
"experimentalDecorators":true,
"sourceMap":true,
"pretty":true,
"allowUnreachableCode":true,
"allowUnusedLabels":true,
"noImplicitAny":true,
"noImplicitReturns":false,
"noImplicitUseStrict":false,
"outDir":"dist/",
"baseUrl":"src/",
"listFiles":false,
"noEmitHelpers":true
},
"include":[
"src/**/*"
],
"exclude":[
"node_modules"
],
"compileOnSave":false
}

Let's now dissect this file and understand the most common options used.