0
  1. Installing ts-node and typescript locally √ 
  2. Add a launch.json file √
{
    "name": "Current TS Tests File",
    "type": "node",
    "request": "launch",
    "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
    "args": ["-r", "ts-node/register", "${relativeFile}"],
    "cwd": "${workspaceRoot}",
    "protocol": "inspector"
}

Open up index.ts, and start the debugger...

Process exited with code 1
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" 
Sumit
  • 2,242
  • 1
  • 24
  • 37
GN.
  • 8,672
  • 10
  • 61
  • 126
  • if you don't compile TS file into JS file you can't debug, read the TS VSC doc page – rioV8 May 09 '22 at 23:54
  • Does this answer your question? [how to debug typescript files in visual studio code](https://stackoverflow.com/questions/31169259/how-to-debug-typescript-files-in-visual-studio-code) – Quentin Dec 07 '22 at 11:09

1 Answers1

0

There is two common options for this.

Use NodeJS:

NodeJS only interprets JavaScript, therefore you will have to cross compile your TypeScript first and enable source maps to use breakpoints. VSCode docs have a thorough tutorial for this.

Use Deno:

Deno interprets TypeScript, therefore it does not require cross compilation. VSCode does not support Deno out of the box, but there is an extension for it, and note that you also need Deno CLI in order for it to work.

Dorin Botan
  • 1,224
  • 8
  • 19