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

Function getUnionOrIntersectionTypePredicate

test/fixtures/snapshot/typescript.js:61356–61387  ·  view source on GitHub ↗
(signatures, kind)

Source from the content-addressed store, hash-verified

61354 return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
61355 }
61356 function getUnionOrIntersectionTypePredicate(signatures, kind) {
61357 var first;
61358 var types = [];
61359 for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) {
61360 var sig = signatures_6[_i];
61361 var pred = getTypePredicateOfSignature(sig);
61362 if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) {
61363 if (kind !== 2097152 /* TypeFlags.Intersection */) {
61364 continue;
61365 }
61366 else {
61367 return; // intersections demand all members be type predicates for the result to have a predicate
61368 }
61369 }
61370 if (first) {
61371 if (!typePredicateKindsMatch(first, pred)) {
61372 // No common type predicate.
61373 return undefined;
61374 }
61375 }
61376 else {
61377 first = pred;
61378 }
61379 types.push(pred.type);
61380 }
61381 if (!first) {
61382 // No signatures had a type predicate.
61383 return undefined;
61384 }
61385 var compositeType = getUnionOrIntersectionType(types, kind);
61386 return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, compositeType);
61387 }
61388 function typePredicateKindsMatch(a, b) {
61389 return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
61390 }

Callers 1

Calls 5

typePredicateKindsMatchFunction · 0.85
createTypePredicateFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected