Config in Typescript

tsconfig.js

tsconfig.js is the configuration file of Typescript used in compiler options, target javascript version, root folder configuration and to set other configuration settings.

run tsc --init comment in terminal to create tsconfig.json file in your project.

// here's the example configuration in tsconfig.json
{
  "compilerOptions": {
    "target": "es2016", /* target js version */
    "module": "commonjs", /* module type */                                
    "rootDir": "./src", /* root directory path */   
    "outDir": "./dist", /* output directory path */                 
    "removeComments": true, /* ignore comments when compile */                            
    "noEmitOnError": true, /* compiler will stop generate output if there are any type error  */                           
    "esModuleInterop": true, /* This setting enables compatibility between CommonJS and ES6-style modules. */
    "forceConsistentCasingInFileNames": true, /* Enforces consistent casing in file names across the project. */           
    "strict": true, /* Enables strict type-checking */                                      
    "skipLibCheck": true /* Skips type-checking for library declaration files */                                
  }
}

run tsc -w to watch your input and generate output when you save .ts file.

Last updated