tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.

1. Open Visual Studio Code
2. Click on Terminal menu
3. Click ‘New Terminal’
4. You will see that Terminal is open at the bottom-most screen of Visual Studio Code
5. Run below command

tsc --init

This will create a tsconfig.json file in your directory where you can define your configuration. VSCode will also start using this file once it finds it in your root directory.

6. We have to compile TypeScript file so that it converts them into JavaScript file. It will keep all the compiled files in temp folder. We are not going to compile node_modules, so we have to exclude.

7. Finally, you should update your tsconfig.json file as

{
	"compilerOptions": {
		"target": "es5",
		"lib": [
			"es5",
			"es6",
			"dom"
		],
		"module": "commonjs",
		"moduleResolution": "node",
		"sourceMap": false,
		"inlineSourceMap": true,
		"declaration": false,
		"removeComments": false,
		"noImplicitAny": false,
		"outDir": "temp",
		"types": [
			"jasmine",
			"node"
		]
	},
	"exclude": [
		"node_modules"
	]
}

You are Done!!!

Reference: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

Leave a Comment