- 配置
launch.json,其中preLaunchTask中的在task.json中配置
{// 使用 IntelliSense 了解相关属性。// 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"type": "node","request": "launch","name": "启动TS","program": "${fileDirname}/${fileBasenameNoExtension}.js","preLaunchTask": "tsc-current","outFiles": ["${workspaceFolder}/**/*.js"]}]}
- 配置
task.json,label与上面使用的相同
{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "tsc-current","type": "shell","command": "tsc ${file} --sourceMap","problemMatcher": ["$tsc"]}]
- 配置忽略编译的
*.js *.map文件,files.exclude配置项
{"editor.fontSize": 18,"editor.formatOnSave": true,"oneDarkPro.italic": false,"files.exclude": {"**/*.js": {"when": "$(basename).ts"},"**/*.map": true,}}
- 配置
tsconfig.json,注意,**module**要选择**CommonJS**,因为使用node环境跑
{"compilerOptions": {"target": "es2015","noImplicitAny": true,"module": "CommonJS","outDir": "./ts/build","sourceMap": true,}
以上配置完成后,在对应ts文件中按F5,就可以编译和调试对应ts文件
