How can I show problems detected by vite checker plugin in VS Code?

1.7k Views Asked by At

I am using the checker plugin for vite. It prints errors to the VS Code terminal, like this (example):

 ERROR(TypeScript)  Property 'foobarasdasdasdas' does not exist on type 'HelloWorld'.
 FILE  /home/birger/SomeFile.tsx:194:23

    192 |
    193 |               // TODO: fix
  > 194 |               return helloWorld.foobarasdasdasdas({
        |                                 ^^^^^^^^^^^^^^^^^
    195 |                       someprop:args,
    196 |                       asd: "",
    197 |                       dsa: "",

However, the "problems" tab in VS Code is silent.

enter image description here

How can I make VS Code detect the errors that is printed to the terminal?

EDIT: I guess I need to configure the task to pick up the output?

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "client dev",
            "type": "npm",
            "script": "dev",
            "problemMatcher": // WHAT DO I WRITE HERE?
        }
    ]
}
2

There are 2 best solutions below

0
On

Add below code to your config file of checker plugin

export default {
  plugins: [checker({ typescript: true /** or an object config */ })],
}
0
On

(https://github.com/fi3ework/vite-plugin-checker/issues/95)

// .vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "client dev",
            "type": "npm",
            "script": "dev",
            "problemMatcher": [
                {
                    "owner": "typescript",
                    "source": "Typescript",
                    "fileLocation": "absolute",
                    "applyTo": "allDocuments",
                    "background": {
                        "activeOnStart": true
                        // "beginsPattern": "sd",
                        // "endsPattern": " > "
                    },
                    "pattern": [
                        {
                            "regexp": "(ERROR|WARNING)\\(TypeScript\\)  (.*)",
                            "severity": 1,
                            "message": 2
                        },
                        {
                            "regexp": "^ FILE  (.*):(\\d*):(\\d*)$",
                            "file": 1,
                            "line": 2,
                            "column": 3
                        }
                    ]
                }
            ]
        }
    ]
}