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

Function structuredTypeRelatedTo

test/fixtures/snapshot/typescript.js:65591–66172  ·  view source on GitHub ↗
(source, target, reportErrors, intersectionState)

Source from the content-addressed store, hash-verified

65589 return result;
65590 }
65591 function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
65592 if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
65593 return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
65594 }
65595 var result;
65596 var originalErrorInfo;
65597 var varianceCheckFailed = false;
65598 var saveErrorInfo = captureErrorCalculationState();
65599 var sourceFlags = source.flags;
65600 var targetFlags = target.flags;
65601 if (relation === identityRelation) {
65602 // We've already checked that source.flags and target.flags are identical
65603 if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) {
65604 var result_8 = eachTypeRelatedToSomeType(source, target);
65605 if (result_8) {
65606 result_8 &= eachTypeRelatedToSomeType(target, source);
65607 }
65608 return result_8;
65609 }
65610 if (sourceFlags & 4194304 /* TypeFlags.Index */) {
65611 return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false);
65612 }
65613 if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) {
65614 if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
65615 if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
65616 return result;
65617 }
65618 }
65619 }
65620 if (sourceFlags & 16777216 /* TypeFlags.Conditional */) {
65621 if (source.root.isDistributive === target.root.isDistributive) {
65622 if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
65623 if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
65624 if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
65625 if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
65626 return result;
65627 }
65628 }
65629 }
65630 }
65631 }
65632 }
65633 if (sourceFlags & 33554432 /* TypeFlags.Substitution */) {
65634 return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false);
65635 }
65636 if (!(sourceFlags & 524288 /* TypeFlags.Object */)) {
65637 return 0 /* Ternary.False */;
65638 }
65639 }
65640 else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) {
65641 if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
65642 return result;
65643 }
65644 if (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */) {
65645 // The combined constraint of an intersection type is the intersection of the constraints of
65646 // the constituents. When an intersection type contains instantiable types with union type
65647 // constraints, there are situations where we need to examine the combined constraint. One is
65648 // when the target is a union type. Another is when the intersection contains types belonging

Callers 1

recursiveTypeRelatedToFunction · 0.85

Calls 15

propertiesRelatedToFunction · 0.85
isRelatedToFunction · 0.85
everyTypeFunction · 0.85
resetErrorInfoFunction · 0.85
isMarkerTypeFunction · 0.85
getAliasVariancesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…