Hide infer type suggestions when using broken versions of ts

Fixes #64395
This commit is contained in:
Matt Bierner
2018-12-04 16:18:30 -08:00
parent f52f29d65e
commit 5010af1171
2 changed files with 12 additions and 1 deletions

View File

@@ -266,7 +266,17 @@ export default class TypeScriptServiceClientHost extends Disposable {
diagnostics: Proto.Diagnostic[],
source: string
): (vscode.Diagnostic & { reportUnnecessary: any })[] {
return diagnostics.map(tsDiag => this.tsDiagnosticToVsDiagnostic(tsDiag, source));
return diagnostics
.filter(tsDiag => {
// See https://github.com/Microsoft/TypeScript/issues/28702
// The infer type suggestions are being returned even when no code action is available.
// Hide these on broken versions of TS because showing them currently is very confusing.
if (tsDiag.code === 7044) {
return !(this.client.apiVersion.gte(API.v320) && this.client.apiVersion.lt(API.v330));
}
return true;
})
.map(tsDiag => this.tsDiagnosticToVsDiagnostic(tsDiag, source));
}
private tsDiagnosticToVsDiagnostic(diagnostic: Proto.Diagnostic, source: string): vscode.Diagnostic & { reportUnnecessary: any } {

View File

@@ -33,6 +33,7 @@ export default class API {
public static readonly v310 = API.fromSimpleString('3.1.0');
public static readonly v314 = API.fromSimpleString('3.1.4');
public static readonly v320 = API.fromSimpleString('3.2.0');
public static readonly v330 = API.fromSimpleString('3.3.0');
public static fromVersionString(versionString: string): API {