(types []*Type, flags IntersectionFlags, alias *TypeAlias)
| 25948 | } |
| 25949 | |
| 25950 | func (c *Checker) getIntersectionTypeEx(types []*Type, flags IntersectionFlags, alias *TypeAlias) *Type { |
| 25951 | var orderedTypes orderedSet[*Type] |
| 25952 | orderedTypes.values = make([]*Type, 0, len(types)) |
| 25953 | includes := c.addTypesToIntersection(&orderedTypes, 0, types) |
| 25954 | typeSet := orderedTypes.values |
| 25955 | objectFlags := ObjectFlagsNone |
| 25956 | // An intersection type is considered empty if it contains |
| 25957 | // the type never, or |
| 25958 | // more than one unit type or, |
| 25959 | // an object type and a nullable type (null or undefined), or |
| 25960 | // a string-like type and a type known to be non-string-like, or |
| 25961 | // a number-like type and a type known to be non-number-like, or |
| 25962 | // a symbol-like type and a type known to be non-symbol-like, or |
| 25963 | // a void-like type and a type known to be non-void-like, or |
| 25964 | // a non-primitive type and a type known to be primitive. |
| 25965 | if includes&TypeFlagsNever != 0 { |
| 25966 | if slices.Contains(typeSet, c.silentNeverType) { |
| 25967 | return c.silentNeverType |
| 25968 | } |
| 25969 | return c.neverType |
| 25970 | } |
| 25971 | if c.strictNullChecks && includes&TypeFlagsNullable != 0 && includes&(TypeFlagsObject|TypeFlagsNonPrimitive|TypeFlagsIncludesEmptyObject) != 0 || |
| 25972 | includes&TypeFlagsNonPrimitive != 0 && includes&(TypeFlagsDisjointDomains&^TypeFlagsNonPrimitive) != 0 || |
| 25973 | includes&TypeFlagsStringLike != 0 && includes&(TypeFlagsDisjointDomains&^TypeFlagsStringLike) != 0 || |
| 25974 | includes&TypeFlagsNumberLike != 0 && includes&(TypeFlagsDisjointDomains&^TypeFlagsNumberLike) != 0 || |
| 25975 | includes&TypeFlagsBigIntLike != 0 && includes&(TypeFlagsDisjointDomains&^TypeFlagsBigIntLike) != 0 || |
| 25976 | includes&TypeFlagsESSymbolLike != 0 && includes&(TypeFlagsDisjointDomains&^TypeFlagsESSymbolLike) != 0 || |
| 25977 | includes&TypeFlagsVoidLike != 0 && includes&(TypeFlagsDisjointDomains&^TypeFlagsVoidLike) != 0 { |
| 25978 | return c.neverType |
| 25979 | } |
| 25980 | if includes&(TypeFlagsTemplateLiteral|TypeFlagsStringMapping) != 0 && includes&TypeFlagsStringLiteral != 0 { |
| 25981 | var isEmptySet bool |
| 25982 | typeSet, isEmptySet = c.extractRedundantTemplateLiterals(typeSet) |
| 25983 | if isEmptySet { |
| 25984 | return c.neverType |
| 25985 | } |
| 25986 | } |
| 25987 | if includes&TypeFlagsAny != 0 { |
| 25988 | switch { |
| 25989 | case includes&TypeFlagsIncludesWildcard != 0: |
| 25990 | return c.wildcardType |
| 25991 | case includes&TypeFlagsIncludesError != 0: |
| 25992 | return c.errorType |
| 25993 | } |
| 25994 | return c.anyType |
| 25995 | } |
| 25996 | if !c.strictNullChecks && includes&TypeFlagsNullable != 0 { |
| 25997 | switch { |
| 25998 | case includes&TypeFlagsIncludesEmptyObject != 0: |
| 25999 | return c.neverType |
| 26000 | case includes&TypeFlagsUndefined != 0: |
| 26001 | return c.undefinedType |
| 26002 | } |
| 26003 | return c.nullType |
| 26004 | } |
| 26005 | if includes&TypeFlagsString != 0 && includes&(TypeFlagsStringLiteral|TypeFlagsTemplateLiteral|TypeFlagsStringMapping) != 0 || |
| 26006 | includes&TypeFlagsNumber != 0 && includes&TypeFlagsNumberLiteral != 0 || |
| 26007 | includes&TypeFlagsBigInt != 0 && includes&TypeFlagsBigIntLiteral != 0 || |
no test coverage detected