Skip to content

Commit

Permalink
revert convertDiagnostics back to its cringe any version because …
Browse files Browse the repository at this point in the history
…somethign somewhere is calling it with the wrong type
  • Loading branch information
DetachHead committed Sep 29, 2024
1 parent 32b8d31 commit 9d85357
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion packages/pyright-internal/src/backgroundAnalysisBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,30 @@ function convertAnalysisResults(result: AnalysisResults): AnalysisResults {
return result;
}

//TODO: refactor this to be type safe somehow and use Diagnostic.copy
function convertDiagnostics(diagnostics: Diagnostic[]) {
return diagnostics.map((d) => d.copy());
// Elements are typed as "any" since data crossing the process
// boundary loses type info.
return diagnostics.map<Diagnostic>((d: any) => {
const diag = new Diagnostic(d.category, d.message, d.range, d.priority, d.baselineStatus);
if (d._actions) {
for (const action of d._actions) {
diag.addAction(action);
}
}

if (d._rule) {
diag.setRule(d._rule);
}

if (d._relatedInfo) {
for (const info of d._relatedInfo) {
diag.addRelatedInfo(info.message, info.uri, info.range);
}
}

return diag;
});
}

export type BackgroundRequestKind =
Expand Down

0 comments on commit 9d85357

Please sign in to comment.