in server/src/utils.ts [86:107]
export function tsRelatedInformationToLspRelatedInformation(
scriptInfo: ts.server.ScriptInfo,
relatedInfo?: ts.DiagnosticRelatedInformation[]): lsp.DiagnosticRelatedInformation[]|undefined {
if (relatedInfo === undefined) return;
const lspRelatedInfo: lsp.DiagnosticRelatedInformation[] = [];
for (const info of relatedInfo) {
if (info.file === undefined || info.start === undefined || info.length === undefined) continue;
const textSpan: ts.TextSpan = {
start: info.start,
length: info.length,
};
const location = lsp.Location.create(
filePathToUri(info.file.fileName),
tsTextSpanToLspRange(scriptInfo, textSpan),
);
lspRelatedInfo.push(lsp.DiagnosticRelatedInformation.create(
location,
ts.flattenDiagnosticMessageText(info.messageText, '\n'),
));
}
return lspRelatedInfo;
}