Last Updated : 16 May, 2022
tsconfig.json file is a file of JSON format which allows us to point the root level files and different compiler options to setup that require to compile a TypeScript based projects. The existence of this file in a project specifies that the given directory is the TypeScript project folder root.
The tsconfig.json file mainly consists of the information for the following:
Let's take an example file of tsconfig.json file and understand the purpose of each of its parts.
tsconfig.json
{
"compileOnSave": true,
"compilerOptions": {
"module": "system",
"noImplicitAny": true,
"removeComments": true,
"allowUnreachableCode": false,
"strictNullChecks": true,
"outFile": "../JS/TypeScript/HelloWorld.js",
"sourceMap": true
},
"files": [
"program.ts",
"sys.ts"
],
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"src/**/*.spec.ts"
]
}
CompilerOptions - It is a property that allows specifying additional options to the TypeScript compiler. Given a list of a few optional settings section of the compilerOptions property that is needed most of the time:
{
"compilerOptions": {
"module": "system",
"noImplicitAny": true,
"removeComments": true,
"allowUnreachableCode": false,
"strictNullChecks": true,
"outFile": "../JS/TypeScript/HelloWorld.js",
"sourceMap": true
}
}
CompileOnSave - It is a property that can be used to instruct the IDE to automatically compile the given TypeScript files and generate the output for the same.
{
"compileOnSave": true,
"compilerOptions": {
"module": "system",
"noImplicitAny": true,
"removeComments": true,
"allowUnreachableCode": false,
"strictNullChecks": true,
"outFile": "../JS/TypeScript/HelloWorld.js",
"sourceMap": true
}
}
Files - It is a property that gives a list of TypeScript files that will be included by the compiler. The URL of the files can be both relative or absolute.
"files": [
"program.ts",
"sys.ts"
]
Include - It is a property that allows you to include a list of TypeScript files using the glob wildcards pattern.
"include": [
"src/**/*"
]
Exclude - It is a property that allows you to exclude a list of TypeScript files using the glob wildcards pattern.
"exclude": [
"node_modules",
"src/**/*.spec.ts"
]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4