I'm using a gulp task in vscode (0.9) to try to get errors from both typescript and tslint.
The gulp task is watching for changes on my ts files and run both the gulp-tslint and gulp-typescript on changes. I also defined a task in vscode tasks.json and problem matchers to parse the results.
The errors are parsed and reported correctly into vscode. However they are sometimes kept even when code is fixed and saved.
Is there some additional config to provide to vscode problem matcher so that it clear errors properly or is it a vscode bug? As a workaround is there a way to manually clear all errors? The only way I found to clear them is to restart vscode which is not great.
Note that this works fine if the task is not a watch task but a simple execution.
My vscode tasks.json
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"tasks": [
{
"taskName": "watch",
// Make this the default build command.
"isBuildCommand": true,
// Watching
"isWatching": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "always",
// Use the standard less compilation problem matcher.
"problemMatcher": [
{
"owner": "gulp-tslint",
"fileLocation": [
"relative",
"${workspaceRoot}/app"
],
"pattern": {
"regexp": ".*\\[gulp-tslint\\] (error|warning) (.*)\\[(\\d*), (\\d*)\\]: (.*)",
"severity": 1,
"file": 2,
"line": 3,
"column": 4,
"message": 5
}
},
{
"owner": "gulp-typescript",
"fileLocation": "absolute",
"pattern": {
"regexp": "\\[gulp-typescript\\] (.*)\\((\\d*),(\\d*)\\): (error|warning) (.*)",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
]
}
]
}
My gulp task definition:
const tslint = require('gulp-tslint');
const typescript = require('gulp-typescript');
gulp.task('watch', function () {
gulp.watch(srcTsFiles, ['tslint', 'compile']);
});
gulp.task('tslint', function () {
return gulp.src(srcTsFiles)
.pipe(tslint())
.pipe(tslint.report('prose', {
emitError: false,
summarizeFailureOutput: true
}));
});
var tsProject = typescript.createProject('tsconfig.json');
gulp.task('compile', function () {
tsProject.src()
.pipe(typescript(tsProject, undefined, typescript.reporter.longReporter()))
.pipe(gulp.dest('dist'));
});
This is a bug in VSCode. Somehow, it doesn't apply any updates to open files. If the files are closed, any obsolete errors are removed.
So, the workaround is to click the little "close all files" icon in the "Working Files" header.
If you want to figure out yourself what the problem is, look into the JS files in the VSCode resources; in OSX, those reside in the application package. Look for workbench.main.js
. You will find the tsc-watch
problem matcher in there, and it will have applyTo:c.ApplyToKind.closedDocuments
set. I tried to change that to allDocuments
, but to no avail.
This is fixed in the latest insider build (I tested it) and will likely go into production next week.
https://github.com/Microsoft/vscode/issues/909
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With