我在vscode (0.9)中使用gulp任务来尝试从typescript和tslint中获取错误。
gulp任务正在监视ts文件的更改,并对更改同时运行gulp-tslint和gulp-typescript。我还在vscode tasks.json和问题匹配器中定义了一个任务来解析结果。
错误被解析并正确地报告到vscode中。然而,即使代码被修复和保存,它们有时也会被保留。
是否有一些额外的配置要提供给vscode问题匹配器,以便它正确地清除错误,或者这是vscode错误?作为一种解决办法,有没有办法手动清除所有错误?我发现清除它们的唯一方法是重新启动vscode,这不是很好。
请注意,如果任务不是监视任务,而是一个简单的执行,则可以很好地工作。
我的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
}
}
]
}
]
}我的吞咽任务定义:
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'));
});发布于 2015-11-17 08:31:36
这是VSCode中的一个错误。不知何故,它不会对打开的文件应用任何更新。如果文件已关闭,则会删除所有过时的错误。
因此,解决方法是单击“工作文件”标题中的小“关闭所有文件”图标。
如果您希望自己找出问题所在,请查看VSCode资源中的JS文件;在OSX中,这些文件位于应用程序包中。查找workbench.main.js。您将在其中找到tsc-watch问题匹配器,并且它将设置applyTo:c.ApplyToKind.closedDocuments。我试图将其更改为allDocuments,但无济于事。
发布于 2015-12-15 19:32:57
这个问题已经在最新的内部版本(我测试过了)中修复了,可能会在下周投入生产。
https://stackoverflow.com/questions/33563049
复制相似问题