You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+21-11Lines changed: 21 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -35846,10 +35846,28 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
35846
35846
if (!result) {
35847
35847
result = chooseOverload(candidates, assignableRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
35848
35848
}
35849
+
const links = getNodeLinks(node);
35850
+
if (links.resolvedSignature !== resolvingSignature && !candidatesOutArray) {
35851
+
// There are 2 situations in which it's good to preemptively return the cached result here:
35852
+
//
35853
+
// 1. if the signature resolution originated on a node that itself depends on the contextual type
35854
+
// then it's possible that the resolved signature might not be the same as the one that would be computed in source order
35855
+
// since resolving such signature leads to resolving the potential outer signature, its arguments and thus the very same signature
35856
+
// it's possible that this inner resolution sets the resolvedSignature first.
35857
+
// In such a case we ignore the local result and reuse the correct one that was cached.
35858
+
//
35859
+
// 2. In certain circular-like situations it's possible that the compiler reentries this function for the same node.
35860
+
// It's possible to resolve the inner call against preemptively set empty members (for example in `resolveAnonymousTypeMembers`) of some type.
35861
+
// When that happens the compiler might report an error for that inner call but at the same time it might end up resolving the actual members of the other type.
35862
+
// This in turn creates a situation in which the outer call fails in `getSignatureApplicabilityError` due to a cached `RelationComparisonResult.Failed`
35863
+
// but when the compiler tries to report that error (in the code below) it also tries to elaborate it and that can succeed as types would be related against the *resolved* members of the other type.
35864
+
// This can hit `No error for last overload signature` assert but since that error was already reported when the inner call failed we can skip this step altogether here by returning the cached signature early.
35865
+
Debug.assert(links.resolvedSignature);
35866
+
return links.resolvedSignature;
35867
+
}
35849
35868
if (result) {
35850
35869
return result;
35851
35870
}
35852
-
35853
35871
result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
35854
35872
// Preemptively cache the result; getResolvedSignature will do this after we return, but
35855
35873
// we need to ensure that the result is present for the error checks below so that if
@@ -35858,7 +35876,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
35858
35876
// don't hit this issue because they only observe this result after it's had a chance to
35859
35877
// be cached, but the error reporting code below executes before getResolvedSignature sets
35860
35878
// resolvedSignature.
35861
-
getNodeLinks(node).resolvedSignature = result;
35879
+
links.resolvedSignature = result;
35862
35880
35863
35881
// No signatures were applicable. Now report errors based on the last applicable signature with
35864
35882
// no arguments excluded from assignability checks.
@@ -36871,19 +36889,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
36871
36889
resolutionStart = resolutionTargets.length;
36872
36890
}
36873
36891
links.resolvedSignature = resolvingSignature;
36874
-
let result = resolveSignature(node, candidatesOutArray, checkMode || CheckMode.Normal);
36892
+
const result = resolveSignature(node, candidatesOutArray, checkMode || CheckMode.Normal);
36875
36893
resolutionStart = saveResolutionStart;
36876
36894
// When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call
36877
36895
// resolution should be deferred.
36878
36896
if (result !== resolvingSignature) {
36879
-
// if the signature resolution originated on a node that itself depends on the contextual type
36880
-
// then it's possible that the resolved signature might not be the same as the one that would be computed in source order
36881
-
// since resolving such signature leads to resolving the potential outer signature, its arguments and thus the very same signature
36882
-
// it's possible that this inner resolution sets the resolvedSignature first.
36883
-
// In such a case we ignore the local result and reuse the correct one that was cached.
36884
-
if (links.resolvedSignature !== resolvingSignature) {
36885
-
result = links.resolvedSignature;
36886
-
}
36887
36897
// If signature resolution originated in control flow type analysis (for example to compute the
36888
36898
// assigned type in a flow assignment) we don't cache the result as it may be based on temporary
mixinWithBaseDependingOnSelfNoCrash1.ts(11,48): error TS2345: Argument of type 'typeof BaseItem' is not assignable to parameter of type 'new (...args: any[]) => any'.
2
+
Type 'typeof BaseItem' provides no match for the signature 'new (...args: any[]): any'.
0 commit comments