简体   繁体   中英

VSCode TypeScript problemMatcher not working

I desire a problem matcher which reports two kinds of problems:

  1. typescript compilation problems
  2. tslint problems

This isn't working in one of my projects, but is working in others. Here is the problem matcher line from the .vscode/tasks.json :

"problemMatcher": [
    "$tsc",
    {
        "owner": "tslint",
        "fileLocation": "relative",
        "severity": "error",
        "pattern": {
            "regexp": "^ERROR:\\s*(.*\\.ts)\\[(\\d+), (\\d+)\\]: (.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "message": 4
        }
    }
]

I believe the problems weren't being picked up, because they were being prefixed by browserify or tsify .

The following configuration solved the problem, and should report problems for regular tsc compilation, browserify/tsify compilation, and tslint:

"problemMatcher": [
    "$tsc",
    {
        "owner": "typescript",
        "fileLocation": ["relative", "${workspaceRoot}"],
        "pattern": {
            "regexp": "^TypeScript (warning|error): (.*)\\((\\d+),(\\d+)\\): (.*)$",
            "severity": 1,
            "file": 2,
            "line": 3,
            "column": 4,
            "message": 5
        }
    },
    {
        "owner": "tslint",
        "fileLocation": "relative",
        "severity": "error",
        "pattern": {
            "regexp": "^ERROR:\\s*(.*\\.ts)\\[(\\d+), (\\d+)\\]: (.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "message": 4
        }
    }
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM