When tsconfig.json
file is generated, it contains a commented line for sourcemap. In order to enable source maps in a TypeScript project, we need to uncomment the line.
{
"compilerOptions": {
//...
"sourceMap": true
}
}
After enabling sourceMap
, when we run tsc
command, along with .js
file, we can also see .js.map
file generated.
![JS Map](/static/js-map-11727e78f7097b2f9db3dfb99e4ca58b.png)
This map file brings the original TypeScript file in the browser sources
tab. It helps us to debug easily by directly viewing the TypeScript files.
![TS file in Sources tab](/static/sources-tab-ts-file-cb994d428e2a76c3ca6af84d84b98da1.png)
We can also place breakpoints in the TypeScript files.