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

Function findMatchingDiscriminantType

test/fixtures/snapshot/typescript.js:89244–89259  ·  view source on GitHub ↗
(source, target, isRelatedTo, skipPartial)

Source from the content-addressed store, hash-verified

89242 }
89243 // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly
89244 function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
89245 if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) {
89246 var match = getMatchingUnionConstituentForType(target, source);
89247 if (match) {
89248 return match;
89249 }
89250 var sourceProperties = getPropertiesOfType(source);
89251 if (sourceProperties) {
89252 var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
89253 if (sourcePropertiesFiltered) {
89254 return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo, /*defaultValue*/ undefined, skipPartial);
89255 }
89256 }
89257 }
89258 return undefined;
89259 }
89260 }
89261 ts.createTypeChecker = createTypeChecker;
89262 function isNotAccessor(declaration) {

Callers 2

hasExcessPropertiesFunction · 0.85
getBestMatchingTypeFunction · 0.85

Calls 6

getPropertiesOfTypeFunction · 0.85
getTypeOfSymbolFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…