One of the things I keep forgetting is how to set up a TypeScript project and debugging it in VSCode.

This blog post will remind me how to do so.

In a new directory, run the following commands and press enter for choosing the default (on the npm init prompts):

  • tsc --init
  • npm init
  • npm i --save-dev @types/node typescript ts-node

In VSCode, do the following:

  • Open a new folder. This is necessary, because without which, VS Code is unable to create an automatic launch configuration.
  • After creating a new TypeScript file, either add a new launch configuration using Run -> Add Configuration, or choose Run -> Start Debugging, then select TS Debug (requires installation of TS Debug aka TypeScript Debugger by kakumei).