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

Function isTypeRelatedTo

test/fixtures/snapshot/typescript.js:64607–64639  ·  view source on GitHub ↗
(source, target, relation)

Source from the content-addressed store, hash-verified

64605 return false;
64606 }
64607 function isTypeRelatedTo(source, target, relation) {
64608 if (isFreshLiteralType(source)) {
64609 source = source.regularType;
64610 }
64611 if (isFreshLiteralType(target)) {
64612 target = target.regularType;
64613 }
64614 if (source === target) {
64615 return true;
64616 }
64617 if (relation !== identityRelation) {
64618 if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) {
64619 return true;
64620 }
64621 }
64622 else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) {
64623 // We have excluded types that may simplify to other forms, so types must have identical flags
64624 if (source.flags !== target.flags)
64625 return false;
64626 if (source.flags & 67358815 /* TypeFlags.Singleton */)
64627 return true;
64628 }
64629 if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) {
64630 var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false));
64631 if (related !== undefined) {
64632 return !!(related & 1 /* RelationComparisonResult.Succeeded */);
64633 }
64634 }
64635 if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) {
64636 return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined);
64637 }
64638 return false;
64639 }
64640 function isIgnoredJsxProperty(source, sourceProp) {
64641 return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName);
64642 }

Callers 12

removeSubtypesFunction · 0.85
isTypeIdenticalToFunction · 0.85
compareTypesIdenticalFunction · 0.85
compareTypesAssignableFunction · 0.85
compareTypesSubtypeOfFunction · 0.85
isTypeSubtypeOfFunction · 0.85
isTypeAssignableToFunction · 0.85
isTypeComparableToFunction · 0.85
elaborateJsxComponentsFunction · 0.85
maybeAddMissingAwaitInfoFunction · 0.85

Calls 5

isFreshLiteralTypeFunction · 0.85
isSimpleTypeRelatedToFunction · 0.85
getRelationKeyFunction · 0.85
checkTypeRelatedToFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…