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" 
2
  • if you don't compile TS file into JS file you can't debug, read the TS VSC doc page Commented May 9, 2022 at 23:54
  • Does this answer your question? how to debug typescript files in visual studio code Commented Dec 7, 2022 at 11:09

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.