How to Load a Typescript Error Log File in Visual Studio Code

Is it possible to load a error log file in VSCode? After piping errors to a file tsc > tsc.log I would like to load the log file and work through the errors in all project files.

2 Answers

I would be surprised if there's anything built-in for this. However, you can easily trick VSCode into "loading the file into the problems panel" by running a task that outputs the file contents and applies the TypeScript problem matcher to that output.

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Load tsc.log",
            "type": "shell",
            "command": "type",
            "args": ["tsc.log"],
            "problemMatcher": ["$tsc"]
        }
    ]
}

(replace the type command with cat if you're not using Windows)


Note that the $tsc problem matcher is only applied to closed files. You could work around this by defining a custom problem matcher that reuses the problem pattern from the TS extension:

"problemMatcher": [
    {
        "pattern": "$tsc",
        "applyTo": "allDocuments"
    }
]

You should be able to just go to File->Open File and choose your log file. Visual Studio Code can open any text encoded file although highlighting and other support/convenience features will depend on your downloaded extensions.

If you go to the extension tab (the square on the left-hand side of the editor) and look up "log" you should find a few log related extensions. Log File Highlighter might be of use for your debugging.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest