在VSCode Typescript构建任务中设置--verbose选项

问题描述 投票:0回答:1

从命令行编译时我可以指定

tsc -b --verbose

但是,我无法弄清楚如何在vs代码中配置默认​​构建任务来执行相同操作。我在tsconfig.json或tasks.json中找不到任何相关条目

typescript visual-studio-code tsc vscode-tasks
1个回答
2
投票

VSCode tasks documentation运行tsc构建任务,有一个特定于TypeScript的布局:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "typescript",
            "tsconfig": "tsconfig.json",
            "problemMatcher": [
                "$tsc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

如果您想运行自己的命令参数或shell命令,我建议使用shell脚本,因为它提供了更多选项,并且可以特定于您要运行的内容:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run tsc verbosely",
            "type": "shell",
            "command": "tsc -b --verbose",
            "group": "test",
            "presentation": {
                "reveal": "always",
                "panel": "new"
            }
        }
    ]
}
© www.soinside.com 2019 - 2024. All rights reserved.