MCPcopy Index your code
hub / github.com/nodejs/node / getImmediateBaseConstraint

Function getImmediateBaseConstraint

test/fixtures/snapshot/typescript.js:58959–58992  ·  view source on GitHub ↗
(t)

Source from the content-addressed store, hash-verified

58957 var stack = [];
58958 return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
58959 function getImmediateBaseConstraint(t) {
58960 if (!t.immediateBaseConstraint) {
58961 if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) {
58962 return circularConstraintType;
58963 }
58964 var result = void 0;
58965 // We always explore at least 10 levels of nested constraints. Thereafter, we continue to explore
58966 // up to 50 levels of nested constraints provided there are no "deeply nested" types on the stack
58967 // (i.e. no types for which five instantiations have been recorded on the stack). If we reach 50
58968 // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
58969 // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
58970 // nesting, so it is effectively just a safety stop.
58971 var identity_1 = getRecursionIdentity(t);
58972 if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
58973 stack.push(identity_1);
58974 result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
58975 stack.pop();
58976 }
58977 if (!popTypeResolution()) {
58978 if (t.flags & 262144 /* TypeFlags.TypeParameter */) {
58979 var errorNode = getConstraintDeclaration(t);
58980 if (errorNode) {
58981 var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t));
58982 if (currentNode && !ts.isNodeDescendantOf(errorNode, currentNode) && !ts.isNodeDescendantOf(currentNode, errorNode)) {
58983 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(currentNode, ts.Diagnostics.Circularity_originates_in_type_at_this_location));
58984 }
58985 }
58986 }
58987 result = circularConstraintType;
58988 }
58989 t.immediateBaseConstraint = result || noConstraintType;
58990 }
58991 return t.immediateBaseConstraint;
58992 }
58993 function getBaseConstraint(t) {
58994 var c = getImmediateBaseConstraint(t);
58995 return c !== noConstraintType && c !== circularConstraintType ? c : undefined;

Callers 2

getBaseConstraintFunction · 0.85

Calls 11

pushTypeResolutionFunction · 0.85
getRecursionIdentityFunction · 0.85
computeBaseConstraintFunction · 0.85
getSimplifiedTypeFunction · 0.85
popTypeResolutionFunction · 0.85
getConstraintDeclarationFunction · 0.85
typeToStringFunction · 0.85
popMethod · 0.80
errorFunction · 0.70
containsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…