我尝试在 tasks.json 中为打字稿类型任务放置一个路径:
{
"version": "2.0.0",
"tasks": [
{
"identifier": "tsc-client",
"label": "tsc-client",
"type": "typescript",
"tsconfig": "src/client/tsconfig.json",
"problemMatcher": [
"$tsc"
]
},
{
"identifier": "tsc-server",
"label": "tsc-server",
"type": "typescript",
"tsconfig": "src/server/tsconfig.json",
"problemMatcher": [
"$tsc"
]
},
{
"identifier": "build-all",
"label": "build-all",
"dependsOn": ["tsc-client", "tsc-server"]
}
]
}
然后在我的 launch.json 我有:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"preLaunchTask": "tsc-client",
"name": "Launch Program",
"program": "${workspaceFolder}/server/server-repsic.js"
}
]
}
我启动它并获得:
Error: The typescript task detection didn't contribute a task for the following configuration:
{
"identifier": "tsc-server",
"label": "tsc-server",
"type": "typescript",
"tsconfig": "src/server/tsconfig.json",
"problemMatcher": [
"$tsc"
]
}
The task will be ignored.
我检查了根路径中是否有src/server/tsconfig.json
and src/client/tsconfig.json
。我也在控制台中输入它:
tsc -p src/client/tsconfig.json
并且命令工作正常。