Skip to content

Commit b20f7ef

Browse files
ahejlsbergJack-Works
authored andcommitted
Explore fewer constraints in getResolvedBaseConstraint (microsoft#48613)
1 parent 60a244e commit b20f7ef

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/compiler/checker.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -12107,7 +12107,7 @@ namespace ts {
1210712107
if (type.resolvedBaseConstraint) {
1210812108
return type.resolvedBaseConstraint;
1210912109
}
12110-
const stack: Type[] = [];
12110+
const stack: object[] = [];
1211112111
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
1211212112

1211312113
function getImmediateBaseConstraint(t: Type): Type {
@@ -12122,8 +12122,9 @@ namespace ts {
1212212122
// levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
1212312123
// yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
1212412124
// nesting, so it is effectively just a safety stop.
12125-
if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) {
12126-
stack.push(t);
12125+
const identity = getRecursionIdentity(t);
12126+
if (stack.length < 10 || stack.length < 50 && !contains(stack, identity)) {
12127+
stack.push(identity);
1212712128
result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
1212812129
stack.pop();
1212912130
}

0 commit comments

Comments
 (0)