(types)
| 61538 | // first with a union containing an intersection of those primitive types, then remove the |
| 61539 | // other unions and return true. Otherwise, do nothing and return false. |
| 61540 | function intersectUnionsOfPrimitiveTypes(types) { |
| 61541 | var unionTypes; |
| 61542 | var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); |
| 61543 | if (index < 0) { |
| 61544 | return false; |
| 61545 | } |
| 61546 | var i = index + 1; |
| 61547 | // Remove all but the first union of primitive types and collect them in |
| 61548 | // the unionTypes array. |
| 61549 | while (i < types.length) { |
| 61550 | var t = types[i]; |
| 61551 | if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { |
| 61552 | (unionTypes || (unionTypes = [types[index]])).push(t); |
| 61553 | ts.orderedRemoveItemAt(types, i); |
| 61554 | } |
| 61555 | else { |
| 61556 | i++; |
| 61557 | } |
| 61558 | } |
| 61559 | // Return false if there was only one union of primitive types |
| 61560 | if (!unionTypes) { |
| 61561 | return false; |
| 61562 | } |
| 61563 | // We have more than one union of primitive types, now intersect them. For each |
| 61564 | // type in each union we check if the type is matched in every union and if so |
| 61565 | // we include it in the result. |
| 61566 | var checked = []; |
| 61567 | var result = []; |
| 61568 | for (var _i = 0, unionTypes_2 = unionTypes; _i < unionTypes_2.length; _i++) { |
| 61569 | var u = unionTypes_2[_i]; |
| 61570 | for (var _a = 0, _b = u.types; _a < _b.length; _a++) { |
| 61571 | var t = _b[_a]; |
| 61572 | if (insertType(checked, t)) { |
| 61573 | if (eachUnionContains(unionTypes, t)) { |
| 61574 | insertType(result, t); |
| 61575 | } |
| 61576 | } |
| 61577 | } |
| 61578 | } |
| 61579 | // Finally replace the first union with the result |
| 61580 | types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); |
| 61581 | return true; |
| 61582 | } |
| 61583 | function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { |
| 61584 | var result = createType(2097152 /* TypeFlags.Intersection */); |
| 61585 | result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); |
no test coverage detected