(types, aliasSymbol, aliasTypeArguments)
| 61599 | // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution |
| 61600 | // for intersections of types with signatures can be deterministic. |
| 61601 | function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { |
| 61602 | var typeMembershipMap = new ts.Map(); |
| 61603 | var includes = addTypesToIntersection(typeMembershipMap, 0, types); |
| 61604 | var typeSet = ts.arrayFrom(typeMembershipMap.values()); |
| 61605 | // An intersection type is considered empty if it contains |
| 61606 | // the type never, or |
| 61607 | // more than one unit type or, |
| 61608 | // an object type and a nullable type (null or undefined), or |
| 61609 | // a string-like type and a type known to be non-string-like, or |
| 61610 | // a number-like type and a type known to be non-number-like, or |
| 61611 | // a symbol-like type and a type known to be non-symbol-like, or |
| 61612 | // a void-like type and a type known to be non-void-like, or |
| 61613 | // a non-primitive type and a type known to be primitive. |
| 61614 | if (includes & 131072 /* TypeFlags.Never */) { |
| 61615 | return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; |
| 61616 | } |
| 61617 | if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || |
| 61618 | includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || |
| 61619 | includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || |
| 61620 | includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || |
| 61621 | includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || |
| 61622 | includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || |
| 61623 | includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { |
| 61624 | return neverType; |
| 61625 | } |
| 61626 | if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { |
| 61627 | return neverType; |
| 61628 | } |
| 61629 | if (includes & 1 /* TypeFlags.Any */) { |
| 61630 | return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; |
| 61631 | } |
| 61632 | if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { |
| 61633 | return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; |
| 61634 | } |
| 61635 | if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || |
| 61636 | includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || |
| 61637 | includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || |
| 61638 | includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */) { |
| 61639 | removeRedundantPrimitiveTypes(typeSet, includes); |
| 61640 | } |
| 61641 | if (includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 524288 /* TypeFlags.Object */) { |
| 61642 | ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); |
| 61643 | } |
| 61644 | if (includes & 262144 /* TypeFlags.IncludesMissingType */) { |
| 61645 | typeSet[typeSet.indexOf(undefinedType)] = missingType; |
| 61646 | } |
| 61647 | if (typeSet.length === 0) { |
| 61648 | return unknownType; |
| 61649 | } |
| 61650 | if (typeSet.length === 1) { |
| 61651 | return typeSet[0]; |
| 61652 | } |
| 61653 | var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); |
| 61654 | var result = intersectionTypes.get(id); |
| 61655 | if (!result) { |
| 61656 | if (includes & 1048576 /* TypeFlags.Union */) { |
| 61657 | if (intersectUnionsOfPrimitiveTypes(typeSet)) { |
| 61658 | // When the intersection creates a reduced set (which might mean that *all* union types have |
no test coverage detected