Improve error messages and related spans

This commit is contained in:
Nathan Shively-Sanders
2019-06-26 10:05:44 -07:00
parent b58932e638
commit 68968fd396
46 changed files with 615 additions and 536 deletions
+13 -12
View File
@@ -21609,18 +21609,19 @@ namespace ts {
let chain: DiagnosticMessageChain | undefined;
if (candidatesForArgumentError.length > 3) {
chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error);
chain = chainDiagnosticMessages(chain, Diagnostics.No_suitable_overload_for_this_call);
chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call);
}
const ds = getSignatureApplicabilityError(node, args, last, assignableRelation, CheckMode.Normal, /*reportErrors*/ true, () => chain);
if (ds) {
// if elaboration already displayed the error, don't do anything extra
// note that we could do this always here, but getSignatureApplicabilityError is currently not configured to do that
for (const d of ds) {
const diags = getSignatureApplicabilityError(node, args, last, assignableRelation, CheckMode.Normal, /*reportErrors*/ true, () => chain);
if (diags) {
for (const d of diags) {
if (last.declaration && candidatesForArgumentError.length > 3) {
addRelatedInfo(d, createDiagnosticForNode(last.declaration, Diagnostics.The_last_overload_is_declared_here));
}
diagnostics.add(d);
}
}
else {
Debug.assert(false, "No error for last overload signature");
Debug.fail("No error for last overload signature");
}
}
else {
@@ -21629,15 +21630,15 @@ namespace ts {
for (const c of candidatesForArgumentError) {
i++;
const chain = () => chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Overload_0_of_1_2_gave_the_following_error, i, candidates.length, signatureToString(c));
const ds = getSignatureApplicabilityError(node, args, c, assignableRelation, CheckMode.Normal, /*reportErrors*/ true, chain);
if (ds) {
related.push(...ds);
const diags = getSignatureApplicabilityError(node, args, c, assignableRelation, CheckMode.Normal, /*reportErrors*/ true, chain);
if (diags) {
related.push(...diags);
}
else {
Debug.assert(false, "No error for 3 or fewer overload signatures");
Debug.fail("No error for 3 or fewer overload signatures");
}
}
diagnostics.add(createDiagnosticForNodeFromMessageChain(node, chainDiagnosticMessages(/*details*/ undefined, Diagnostics.No_suitable_overload_for_this_call), related));
diagnostics.add(createDiagnosticForNodeFromMessageChain(node, chainDiagnosticMessages(/*details*/ undefined, Diagnostics.No_overload_matches_this_call), related));
}
}
else if (candidateForArgumentArityError) {
+15 -3
View File
@@ -2621,18 +2621,30 @@
"category": "Error",
"code": 2754
},
"No suitable overload for this call.": {
"No overload matches this call.": {
"category": "Error",
"code": 2755
},
"The last overload gave the following error.": {
"The closest overload gave the following error.": {
"category": "Error",
"code": 2756
},
"Overload {0} of {1}, '{2}', gave the following error.": {
"The closest overload is declared here.": {
"category": "Error",
"code": 2757
},
"The last overload gave the following error.": {
"category": "Error",
"code": 2758
},
"The last overload is declared here.": {
"category": "Error",
"code": 2759
},
"Overload {0} of {1}, '{2}', gave the following error.": {
"category": "Error",
"code": 2760
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",