假如需要调试 /src/main.ts,则此处为 ${workspaceRoot}/dist/main.js。
调试
打开 main.ts,在左侧添加断点,进行调试。
使用 ts-node 调试 ts 文件
源码:github(https://github.com/meteor199/my-demo/tree/master/typescript/vscode-debug-without-compiling)
来自:Debugging TypeScript in VS Code without compiling, using ts-node
ts-node 调试 ts 文件时,不会显式生成 js。假如你不想编译为 js 后 再调试,可以考虑这种方式。
安装 npm 依赖包
1 2 |
|
配置 tsconfig.json
主要是将 sourceMap 设置为true。
1 2 3 4 5 6 7 8 9 10 11 12 |
|
配置 launch.json
打开 DEBUG 界面,添加 配置
或者编辑 /.vscode/launch.json。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
调试
打开要调试的 ts 文件,添加debugger。
打开 debug 界面。
在DEBUG后 选择 launch.json 中对应的配置,此处为Current TS File。
点击运行按键或者按 F5 运行。
相关教程推荐:vscode教程
以上就是vscode怎么调试ts的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
更多相关阅读请进入《vsCode》频道 >>