在 Visual Studio 程式碼中使用 ts 節點鍵入 TypeScript

將 ts 節點新增到 TypeScript 專案:

npm i ts-node

新增指令碼到 package.json

"start:debug": "ts-node --inspect=5858 --debug-brk --ignore false index.ts"

需要將 launch.json 配置為使用 node2 型別並啟動執行 start:debug 指令碼的 npm:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node2",
            "request": "launch",
            "name": "Launch Program",
            "runtimeExecutable": "npm",
            "windows": {
                "runtimeExecutable": "npm.cmd"
            },
            "runtimeArgs": [
                "run-script",
                "start:debug"
            ],
            "cwd": "${workspaceRoot}/server",
            "outFiles": [],
            "port": 5858,
            "sourceMaps": true
        }
    ]
}