tsconfig.json配置
// tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"rootDir": "./src",
"allowJs": true,
"sourceMap": true,
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
vscode配置
// tasks.json
{
"version": "2.0.0",
"tasks": [
{
// 执行命令
"type": "shell",
// 编译所有ts文件至${workspaceFolder}/dist
"command": "tsc",
// 语法检查器(注:不能用$tsc-watch)
"problemMatcher": [
"$tsc"
],
// 执行标签
"label": "tsc: build - tsconfig.json"
}
]
}
// launch.json
{
// 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",
"skipFiles": [
"<node_internals>/**"
],
// 调试的目标文件
"program": "dist/sketch-1.js",
// 忽略检查的文件
"outFiles": [
"${workspaceFolder}/**/*.js"
],
// 执行tasks.json的任务
"preLaunchTask": "tsc: build - tsconfig.json"
}
]
}