* 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)
| 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) { |
no test coverage detected
searching dependent graphs…