We need to inform Visual Studio about the compiler options required to compile TypeScript for our application to consume when it is running. With the help of a TypeScript configuration file, we can configure the compiler options and other details using the following steps:
- Let's add TypeScript Configuration File by right-clicking on the project and navigating to Add | New Item in the menu, leaving the filename to default, as shown in this screenshot:
Adding the TypeScript configuration file
A file named tsconfig.json will be added to the project root directory.
- Replace the content of the TypeScript configuration file with the following configuration:
{
"compilerOptions":
{
"diagnostics": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom"],
"listFiles": true,
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"outDir": "wwwroot",
"removeComments": false,
"rootDir": "wwwroot",
"sourceMap": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es5"
},
"exclude": [
"node_modules"
]
}