Seb*_*ien 11 tsc gulp tslint visual-studio-code
我在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
}
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
我的gulp任务定义:
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'));
});
Run Code Online (Sandbox Code Playgroud)
这是 VSCode 中的一个错误。不知何故,它不会对打开的文件应用任何更新。如果关闭文件,所有过时的错误都会被删除。
因此,解决方法是单击“工作文件”标题中的“关闭所有文件”小图标。
如果你想自己找出问题所在,请查看 VSCode 资源中的 JS 文件;在 OSX 中,它们驻留在应用程序包中。寻找workbench.main.js
。您会在那里找到tsc-watch
问题匹配器,并且它已经applyTo:c.ApplyToKind.closedDocuments
设置。我试图将其更改为allDocuments
,但无济于事。
归档时间: |
|
查看次数: |
971 次 |
最近记录: |