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

8

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

tsc -b --verbose

但是我不知道如何在vs code中配置默认的构建任务以实现相同的功能。 我找不到任何相关的条目在tsconfig.jsontasks.json中。

1个回答

8

VSCode任务文档中运行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"
            }
        }
    ]
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接