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

Function narrowUnionMemberByTypeof

test/fixtures/snapshot/typescript.js:71120–71136  ·  view source on GitHub ↗
(candidate)

Source from the content-addressed store, hash-verified

71118 // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71119 // filtering by type-facts.
71120 function narrowUnionMemberByTypeof(candidate) {
71121 return function (type) {
71122 if (isTypeSubtypeOf(type, candidate)) {
71123 return type;
71124 }
71125 if (isTypeSubtypeOf(candidate, type)) {
71126 return candidate;
71127 }
71128 if (type.flags & 465829888 /* TypeFlags.Instantiable */) {
71129 var constraint = getBaseConstraintOfType(type) || anyType;
71130 if (isTypeSubtypeOf(candidate, constraint)) {
71131 return getIntersectionType([type, candidate]);
71132 }
71133 }
71134 return type;
71135 };
71136 }
71137 function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71138 var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
71139 if (!switchWitnesses.length) {

Callers 2

narrowTypeByTypeofFunction · 0.85
narrowBySwitchOnTypeOfFunction · 0.85

Calls 3

isTypeSubtypeOfFunction · 0.85
getBaseConstraintOfTypeFunction · 0.85
getIntersectionTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…