mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Fix get candidate for overload failure checking (#36744)
* getCandidateForOverloadFailure:call resolveUntypedCall This re-adds the missed errors and marks as used missed nodes from the user and RWC baselines. * Update baselines and remove new test It was redundant with the old tests * Defer resolveUntypedCall on resolution failure to give priority to parameter types fixed by overload signatures Co-authored-by: Wesley Wigham <wwigham@gmail.com>
This commit is contained in:
committed by
GitHub
parent
6f079a4ebc
commit
01c86c749d
@@ -22600,6 +22600,7 @@ namespace ts {
|
||||
|
||||
function checkJsxSelfClosingElementDeferred(node: JsxSelfClosingElement) {
|
||||
checkJsxOpeningLikeElementOrOpeningFragment(node);
|
||||
resolveUntypedCall(node); // ensure type arguments and parameters are typechecked, even if there is an arity error
|
||||
}
|
||||
|
||||
function checkJsxSelfClosingElement(node: JsxSelfClosingElement, _checkMode: CheckMode | undefined): Type {
|
||||
@@ -24987,7 +24988,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
// No signature was applicable. We have already reported the errors for the invalid signature.
|
||||
// If this is a type resolution session, e.g. Language Service, try to get better information than anySignature.
|
||||
function getCandidateForOverloadFailure(
|
||||
node: CallLikeExpression,
|
||||
candidates: Signature[],
|
||||
@@ -24995,6 +24995,7 @@ namespace ts {
|
||||
hasCandidatesOutArray: boolean,
|
||||
): Signature {
|
||||
Debug.assert(candidates.length > 0); // Else should not have called this.
|
||||
checkNodeDeferred(node);
|
||||
// Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine.
|
||||
// Don't do this if there is a `candidatesOutArray`,
|
||||
// because then we want the chosen best candidate to be one of the overloads, not a combination.
|
||||
@@ -33913,6 +33914,16 @@ namespace ts {
|
||||
currentNode = node;
|
||||
instantiationCount = 0;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.Decorator:
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
// These node kinds are deferred checked when overload resolution fails
|
||||
// To save on work, we ensure the arguments are checked just once, in
|
||||
// a deferred way
|
||||
resolveUntypedCall(node as CallLikeExpression);
|
||||
break;
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
|
||||
Reference in New Issue
Block a user