mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 05:17:43 -05:00
Improve multiple overloads error span (#32315)
* Improve multiple overloads error span When all errors for a multiple-overload error refer to the same span, use that span instead of the one for the entire call. This situation is quite common for 2-overload sets in React. * Update baselines * Fix lint
This commit is contained in:
committed by
GitHub
parent
b0f050f4ee
commit
949956b586
@@ -21836,9 +21836,18 @@ namespace ts {
|
||||
}
|
||||
|
||||
const diags = max > 1 ? allDiagnostics[minIndex] : flatten(allDiagnostics);
|
||||
const chain = map(diags, d => typeof d.messageText === "string" ? (d as DiagnosticMessageChain) : d.messageText);
|
||||
Debug.assert(diags.length > 0, "No errors reported for 3 or fewer overload signatures");
|
||||
const chain = chainDiagnosticMessages(
|
||||
map(diags, d => typeof d.messageText === "string" ? (d as DiagnosticMessageChain) : d.messageText),
|
||||
Diagnostics.No_overload_matches_this_call);
|
||||
const related = flatMap(diags, d => (d as Diagnostic).relatedInformation) as DiagnosticRelatedInformation[];
|
||||
diagnostics.add(createDiagnosticForNodeFromMessageChain(node, chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call), related));
|
||||
if (every(diags, d => d.start === diags[0].start && d.length === diags[0].length && d.file === diags[0].file)) {
|
||||
const { file, start, length } = diags[0];
|
||||
diagnostics.add({ file, start, length, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related });
|
||||
}
|
||||
else {
|
||||
diagnostics.add(createDiagnosticForNodeFromMessageChain(node, chain, related));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (candidateForArgumentArityError) {
|
||||
|
||||
Reference in New Issue
Block a user