+1 vote
in Angular by

Explain tsconfig.json file.

2 Answers

0 votes
by

This file is used to give the options about TypeScript used for the Angular JS project.

   "compilerOptions": { 

      "target": "es5", 

      "module": "commonjs", 

      "moduleResolution": "node", 

      "sourceMap": true, 

      "emitDecoratorMetadata": true, 

      "experimentalDecorators": true, 

      "lib": [ "es2015", "dom" ], 

      "noImplicitAny": true, 

      "suppressImplicitAnyIndexErrors": true 

   } 

}

Following are some key points to note about the above code.

The target for the compilation is es5 and that is because most browsers can only understand ES5 typescript.

The sourceMap option is used to generate Map files, which are useful when debugging. Hence, during development it is good to keep this option as true.

The "emitDecoratorMetadata": true and "experimentalDecorators": true is required for Angular JS decorators. If not in place, Angular JS application will not compile.

0 votes
by

The tsconfig.json file is a file which is in JSON format. In the tsconfig.json file, we can specify various options to tell the compiler how to compile the current project. The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. Below is a sample tsconfig.json file.

{  

   "compilerOptions": {  

      "declaration": true,      

      "emitDecoratorMetadata": false,      

      "experimentalDecorators": false,      

      "module": "none",      

      "moduleResolution": "node"  

      "removeComments": true,  

      "sourceMap": true  

   },  

   "files": [  

      "main.ts",  

      "othermodule.ts"  

    ]  

}  

...