Skip to content

Commit da48d42

Browse files
committed
Add support for reading related error spans from tsserver
1 parent 549c1a1 commit da48d42

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

extensions/typescript-language-features/src/typeScriptServiceClientHost.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* https://github.com/Microsoft/TypeScript-Sublime-Plugin/blob/master/TypeScript%20Indent.tmPreferences
99
* ------------------------------------------------------------------------------------------ */
1010

11-
import { workspace, Memento, Diagnostic, Range, Disposable, Uri, DiagnosticSeverity, DiagnosticTag } from 'vscode';
11+
import { workspace, Memento, Diagnostic, Range, Disposable, Uri, DiagnosticSeverity, DiagnosticTag, DiagnosticRelatedInformation } from 'vscode';
1212

1313
import * as Proto from './protocol';
1414
import * as PConst from './protocol.const';
@@ -263,6 +263,15 @@ export default class TypeScriptServiceClientHost {
263263
if (diagnostic.code) {
264264
converted.code = diagnostic.code;
265265
}
266+
if (diagnostic.relatedInformation) {
267+
converted.relatedInformation = diagnostic.relatedInformation.map(info => {
268+
let span = info.span;
269+
if (!span) {
270+
return undefined;
271+
}
272+
return new DiagnosticRelatedInformation(typeConverters.Location.fromTextSpan(this.client.asUrl(span.file), span), info.message);
273+
}).filter(x => !!x) as DiagnosticRelatedInformation[];
274+
}
266275
if (diagnostic.reportsUnnecessary) {
267276
converted.customTags = [DiagnosticTag.Unnecessary];
268277
}

0 commit comments

Comments
 (0)