VSCode在文件夹打开时未运行任务

时间:2019-04-30 14:35:59

标签: visual-studio-code vscode-tasks

我正在使用TypeScript,并且经常不得不手动启动class CustomArray { constructor(size) { this.arr = new Array(size) } describe() { console.log(this.arr.length) this.arr.forEach(num => console.log(num)) } insert(idx, val) { this.arr.splice(idx, 1, val) } remove(idx) { delete this.arr[idx] } remove2(idx) { this.arr.splice(idx, 1) } } let myArr = new CustomArray(20) myArr.insert(3, 100) myArr.remove(3) myArr.describe()任务。根据博客VSCode v1.30 +可以MDN使用,但这对我不起作用(v1.33.1)-我打开了文件夹,没有任何任务在运行。 automatically run tasks when a folder is opened

tsc-watch

顺便说一句:还尝试了enter image description here,它也没有启动任务。

1 个答案:

答案 0 :(得分:2)

此功能在VSCode 1.42.1版我的task.json中

    {
     "version": "2.0.0",
     "tasks": [
        {
            "type": "typescript",
            "tsconfig": "tsconfig.json",
            "label": "TypeScript Compiler Watching...",
            "option": "watch",
            "presentation": {
                "echo": true,
                "reveal": "silent",
                "focus": false,
                "panel": "shared"
            },
            "isBackground": true,
            "runOptions": {"runOn": "folderOpen"},
            "problemMatcher": [
                "$tsc-watch"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
   }

如果在项目文件夹上仍然无法使用,请尝试按Ctrl + shift + P和Tasks: Manage Automatic Tasks in Folder,然后在主项目文件夹或运行文件夹中选择“允许文件夹中的自动任务”。