Skip to content

Commit b7bbf2b

Browse files
committed
Explore fewer constraints in getResolvedBaseConstraint
1 parent a3c2218 commit b7bbf2b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12063,7 +12063,7 @@ namespace ts {
1206312063
if (type.resolvedBaseConstraint) {
1206412064
return type.resolvedBaseConstraint;
1206512065
}
12066-
const stack: Type[] = [];
12066+
const stack: object[] = [];
1206712067
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
1206812068

1206912069
function getImmediateBaseConstraint(t: Type): Type {
@@ -12078,8 +12078,9 @@ namespace ts {
1207812078
// levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
1207912079
// yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
1208012080
// nesting, so it is effectively just a safety stop.
12081-
if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) {
12082-
stack.push(t);
12081+
const identity = getRecursionIdentity(t);
12082+
if (stack.length < 10 || stack.length < 50 && !contains(stack, identity)) {
12083+
stack.push(identity);
1208312084
result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
1208412085
stack.pop();
1208512086
}

0 commit comments

Comments
 (0)