Lasantha Basnayake Lasantha Basnayake - 3 months ago 15
TypeScript Question

How to debug Angular 2 Typescript application

How to debug Angular 2 Typescript application using visual code or with the developer tools?

Answer

What is important at this level is source maps. They allow you to link TypeScript source code to the transpiled JavaScript one.

There is a sourceMap option in your tsconfig.json file that must be set to true:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true, // <-----
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false

} }

You'll then be able to see your TypeScript files within the Sources tab of DevTools and to add breakpoints in them.

This article could also interest you: