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

Function getReducedType

test/fixtures/snapshot/typescript.js:59344–59356  ·  view source on GitHub ↗

* Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. * For an intersection of types containing one or more mututally exclusive discriminant properties, it is 'never'. * For all other types, it is simply the type itself. D

(type)

Source from the content-addressed store, hash-verified

59342 * no constituent property has type 'never', but the intersection of the constituent property types is 'never'.
59343 */
59344 function getReducedType(type) {
59345 if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) {
59346 return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type));
59347 }
59348 else if (type.flags & 2097152 /* TypeFlags.Intersection */) {
59349 if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) {
59350 type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ |
59351 (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0);
59352 }
59353 return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type;
59354 }
59355 return type;
59356 }
59357 function getReducedUnionType(unionType) {
59358 var reducedTypes = ts.sameMap(unionType.types, getReducedType);
59359 if (reducedTypes === unionType.types) {

Callers 15

typeToTypeNodeHelperFunction · 0.85
resolveBaseTypesOfClassFunction · 0.85
getReducedApparentTypeFunction · 0.85
getIndexTypeFunction · 0.85
instantiateMappedTypeFunction · 0.85
getNormalizedTypeFunction · 0.85
inferFromTypesFunction · 0.85
checkObjectLiteralFunction · 0.85

Calls 3

getReducedUnionTypeFunction · 0.85
someMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…