How to load a TypeScript error log file in Visual Studio Code

May 2024 ยท 2 minute read

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

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobGxxZmaEdIWOoaawZaSkeq27wJ1kmmWkrr2mv8KroKmsXZq%2Fs7vRZqOon12btq2xjKKlZq6ZqMKiuIysq66cmaR6pLvDng%3D%3D