TypeScript在VS Code中调试

280 阅读1分钟

vscode配置

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "runtimeArgs": [
                "-r",
                "ts-node/register"
              ],
              "args": [
                "${workspaceFolder}/test/test.ts"  // 这里是需要调试的文件路径
              ]
        }
    ]
}

遇到问题

按F5运行,发现报错: Type error: Cannot compile namespaces when the '--isolatedModules' flag is provided. 在test.ts文件最后增加

export {};

报错消失