Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode TypeScript problemMatcher `$tsc-watch` not watching

I'm trying to avoid having to use watch: true in a tsconfig.json configuration.

Through VSCode's tasks I'm using the base problem matcher $tsc-watch but it's not launching tsc in watch mode when building. I'm adding gulp support and I see there is gulp-watch but I'd like to understand why $tsc-watch isn't working as I believe it should.

like image 757
happycodelucky Avatar asked Mar 12 '18 00:03

happycodelucky


People also ask

Where is task json in VS Code?

You need to configure the tasks in a tasks. json file (located under your workspace . vscode folder) if you want to do more than simply run the task.

How do I run a task in VS Code?

Task auto-detection Below is an example of the tasks detected for the vscode-node-debug extension. Tip: You can run your task through Quick Open (Ctrl+P) by typing 'task', Space and the command name.

How do I auto compile in Visual Studio code?

Press Ctrl+Shift+B to open a list of tasks in VS Code and select tsc: watch - tsconfig. json . Done! Your project is recompiled on every file save.

What is task json?

tasks. json is used to execute anything else you may want, be that source code formatters, bundlers or a SASS compiler. To use a configuration from tasks. json , you select Run Task from the command list.


1 Answers

I figured this out by looking at the typescript extension's taskProvider.js. In order for tsc-watch to function the task needed option: "watch" to be set.

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "typescript",
            "tsconfig": "tsconfig.json",
            "isBackground": true,
            "problemMatcher": ["$tsc-watch"],
            "option": "watch",
            "presentation": {
                "echo": true,
                "reveal": "silent",
                "focus": false,
                "panel": "shared"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
like image 65
happycodelucky Avatar answered Sep 22 '22 15:09

happycodelucky