IntelliJ IDEA 2016.3 Help

Debugging TypeScript

This feature is supported in the Ultimate edition only.

TypeScript code is not processed by browsers that work with JavaScript code. Therefore to be executed, TypeScript code has to be translated into JavaScript. This operation is referred to as transpilation and the tools that perform it are called transpilers.

In addition to this, transpilation also can involve generation of source maps that set correspondence between lines in your TypeScript code and in the generated JavaScript code, otherwise your breakpoints will not be recognised and processed correctly.

Because JavaScript debugging is supported only in Google Chrome and other browsers of the Chrome family, TypeScript can also be debugged only in these browsers.

To debug TypeScript code:

  1. Transpile the TypeScript code into Javascript using the built-in compiler, see Transpiling TypeScript to JavaScript for details.
  2. In the editor, open the HTML files with the TypeScript references.
  3. Manually replace the references to the TypeScript files with the references to the JavaScript files that were generated through the transpilation.
  4. Configure the JavaScript debugger.
  5. Configure and set breakpoints in the TypeScript code. Although actually debugging will be performed against the generated JavaScript, IntelliJ IDEA will emulate TypeScript debugging using the generated source-maps that set correspondence between lines in the TypeScript and in the JavaScript code.
  6. Proceed as if you were debugging JavaScript:
    1. Initiate a debugging session. For details about local and remote debugging, about debugging single files and entire applications, see Debugging JavaScript.
    2. If you are using Chrome, install and configure the JetBrains Chrome Extension. For details, see Using JetBrains Chrome Extension.
    3. Step through the program, stop and resume program execution, examine it when suspended, etc.

See Also

Last modified: 21 March 2017