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

Function typeRelatedToSomeType

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

Source from the content-addressed store, hash-verified

65312 return result;
65313 }
65314 function typeRelatedToSomeType(source, target, reportErrors) {
65315 var targetTypes = target.types;
65316 if (target.flags & 1048576 /* TypeFlags.Union */) {
65317 if (containsType(targetTypes, source)) {
65318 return -1 /* Ternary.True */;
65319 }
65320 var match = getMatchingUnionConstituentForType(target, source);
65321 if (match) {
65322 var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false);
65323 if (related) {
65324 return related;
65325 }
65326 }
65327 }
65328 for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
65329 var type = targetTypes_1[_i];
65330 var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false);
65331 if (related) {
65332 return related;
65333 }
65334 }
65335 if (reportErrors) {
65336 // Elaborate only if we can find a best matching type in the target union
65337 var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
65338 if (bestMatchingType) {
65339 isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true);
65340 }
65341 }
65342 return 0 /* Ternary.False */;
65343 }
65344 function typeRelatedToEachType(source, target, reportErrors, intersectionState) {
65345 var result = -1 /* Ternary.True */;
65346 var targetTypes = target.types;

Callers 2

Calls 4

containsTypeFunction · 0.85
isRelatedToFunction · 0.85
getBestMatchingTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…