2015-11-06 19 views
11

我在vscode(0.9)中使用gulp任务尝试从typecript和tslint中获取错误。在vscode中,具有isWatching的任务生成的错误在被修复后并不总是被清除

吞噬任务正在监视我的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')); 
}); 

回答

3

这是VSCode的错误。不知何故,它不会应用任何更新来打开文件。如果文件关闭,则会删除任何过时的错误。

因此,解决方法是单击“工作文件”标题中的小“关闭所有文件”图标。

如果您想弄清楚自己的问题是什么,请查看VSCode资源中的JS文件;在OSX中,那些驻留在应用程序包中。寻找workbench.main.js。您会在那里找到tsc-watch问题匹配器,它将设置applyTo:c.ApplyToKind.closedDocuments。我试图将其更改为allDocuments,但无济于事。

+1

仍然发生在当前版本的VSCode中。 –

+0

在官方回购上创建了一个问题.. https://github.com/Microsoft/vscode/issues/1229 –

相关问题