IntelliJ IDEA 2017.2 Help

Debugging TypeScript

This feature is supported in the Ultimate edition only.

Introduction

Before debugging, you need to compile your code into JavaScript. You can do that using the built-in compiler or another tool of your choice.

IntelliJ IDEA needs source maps to recognize breakpoints you set in the TypeScript code. To have source maps generated during compilation, open the tsconfig.json file and make sure the sourceMap property is set to true.

Before you start, install the JetBrains IDE Support Chrome extension. Find more about that and about additional configuration of the debugger in Configuring JavaScript Debugger and JetBrains Chrome Extension.

Debugging client-side TypeScript

Most often, you may want to debug a client-side application running on an external development web server, e.g. powered by Node.js.

  1. Configure and set breakpoints in the TypeScript code.
  2. Compile the TypeScript code into JavaScript using the built-in compiler or as a part of your build process.
  3. Run the application in the development mode. Often you need to run npm start for that. When the development server is ready, copy the URL address at which the application is running in the browser - you will need to specify this URL address in the run/debug configuration.
  4. Create a debug configuration of the type JavaScript Debug:
    Choose Run | Edit Configuration on the main menu, click the Add New Configuration button /help/img/idea/2017.2/add.png on the toolbar, and select JavaScript Debug from the pop-up list.
  5. In the Run/Debug Configuration: JavaScript Debug dialog box that opens, specify the URL address at which the application is running. This URL can be copied from the address bar of your browser as described in Step 3 above. Click OK to save the configuration settings.
  6. Choose the newly created configuration in the Select run/debug configuration drop-down list on the toolbar and click the Debug toolbar button /help/img/idea/2017.2/debug.png. The URL address specified in the run configuration opens in the chosen browser and the Debug tool window appears.
  7. In the Debug tool window, proceed as usual: step through the program, stop and resume program execution, examine it when suspended, view actual HTML DOM, etc.

If your TypeScript code is running on the built-in IntelliJ IDEA server, you can also debug it same ways as when debugging JavaScript running on the built-in server.

Last modified: 26 October 2017

See Also