Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the purpose of tsconfig.json?

I was reading angular2 referrences and found this tsconfig.json. I would like to know what the following parameters mean?

{     "compilerOptions": {         "target": "es5",         "module": "system",         "moduleResolution": "node",         "sourceMap": true,         "emitDecoratorMetadata": true,         "experimentalDecorators": true,         "removeComments": false,         "noImplicitAny": false     },     "exclude": [         "node_modules"     ] } 
like image 728
Bhushan Gadekar Avatar asked May 24 '16 12:05

Bhushan Gadekar


People also ask

What is Lib in Tsconfig json?

TypeScript includes a default set of type definitions for built-in JS APIs (like Math ), as well as type definitions for things found in browser environments (like document ).

Where do I put Tsconfig json?

The tsconfig. json is generally put in the root folder of the project.

Which of the following is correct about Tsconfig json?

Correct Answer : Option (C) : This file is used to give the options about TypeScript used for the Angular JS project.


2 Answers

The tsconfig.json file corresponds to the configuration of the TypeScript compiler (tsc).

These links could give you details about these attributes:

  • http://www.typescriptlang.org/docs/handbook/tsconfig-json.html
  • http://json.schemastore.org/tsconfig
  • https://angular.io/docs/ts/latest/guide/typescript-configuration.html#!#tsconfig

Here are some hints:

  • target: the language used for the compiled output
  • module: the module manager used in the compiled output. system is for SystemJS, commonjs for CommonJS.
  • moduleResolution: the strategy used to resolve module declaration files (.d.ts files). With the node approach, they are loaded from the node_modules folder like a module (require('module-name'))
  • sourceMap: generate or not source map files to debug directly your application TypeScript files in the browser,
  • emitDecoratorMetadata: emit or not design-type metadata for decorated declarations in source,
  • experimentalDecorators: enables or not experimental support for ES7 decorators,
  • removeComments: remove comments or not
  • noImplicitAny: allow or not the use of variables / parameters without types (implicit)
like image 113
Thierry Templier Avatar answered Oct 04 '22 04:10

Thierry Templier


tsconfig.json signifies the directory in which it is kept is the root of TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.

The compiler is expected to execute as per the configurations mentioned:

"target": "es5" => will compile the es6 to es5 so that it is compatible browsers.

"module": "system" => specifies the module code generations (commonjs', 'amd', 'system', 'umd', 'es6' etc)

"moduleResolution": "node" => Determine how modules get resolved

"sourceMap": true => Generates corresponding ‘.map’ file so that it can be used in the production code for debugging.

"removeComments": false => Remove all comments except copy-right header comments beginning with /*!

"noImplicitAny": false => Raise error on expressions and declarations with an implied ‘any’ type.

If the "exclude" property is specified, the compiler includes all TypeScript (*.ts or *.tsx) files in the containing directory and subdirectories except for those files or folders that are excluded.

like image 29
Soumya Avatar answered Oct 04 '22 03:10

Soumya