mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 00:55:32 -05:00
Add isDeeplyNestedType logic to getResolvedBaseConstraint (#40971)
* Add isDeeplyNestedType logic to getResolvedBaseConstraint * Accept new baselines * Add regression test * Accept new baselines * Fix lint issue
This commit is contained in:
@@ -10913,9 +10913,12 @@ namespace ts {
|
||||
* circularly references the type variable.
|
||||
*/
|
||||
function getResolvedBaseConstraint(type: InstantiableType | UnionOrIntersectionType): Type {
|
||||
if (type.resolvedBaseConstraint) {
|
||||
return type.resolvedBaseConstraint;
|
||||
}
|
||||
let nonTerminating = false;
|
||||
return type.resolvedBaseConstraint ||
|
||||
(type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type));
|
||||
const stack: Type[] = [];
|
||||
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
|
||||
|
||||
function getImmediateBaseConstraint(t: Type): Type {
|
||||
if (!t.immediateBaseConstraint) {
|
||||
@@ -10932,9 +10935,14 @@ namespace ts {
|
||||
nonTerminating = true;
|
||||
return t.immediateBaseConstraint = noConstraintType;
|
||||
}
|
||||
constraintDepth++;
|
||||
let result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
|
||||
constraintDepth--;
|
||||
let result;
|
||||
if (!isDeeplyNestedType(t, stack, stack.length)) {
|
||||
stack.push(t);
|
||||
constraintDepth++;
|
||||
result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
|
||||
constraintDepth--;
|
||||
stack.pop();
|
||||
}
|
||||
if (!popTypeResolution()) {
|
||||
if (t.flags & TypeFlags.TypeParameter) {
|
||||
const errorNode = getConstraintDeclaration(<TypeParameter>t);
|
||||
|
||||
Reference in New Issue
Block a user