(type, readonly)
| 62860 | return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); |
| 62861 | } |
| 62862 | function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { |
| 62863 | if (!(type.flags & 1048576 /* TypeFlags.Union */)) { |
| 62864 | return type; |
| 62865 | } |
| 62866 | if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { |
| 62867 | return ts.find(type.types, isEmptyObjectType) || emptyObjectType; |
| 62868 | } |
| 62869 | var firstType = ts.find(type.types, function (t) { return !isEmptyObjectTypeOrSpreadsIntoEmptyObject(t); }); |
| 62870 | if (!firstType) { |
| 62871 | return type; |
| 62872 | } |
| 62873 | var secondType = ts.find(type.types, function (t) { return t !== firstType && !isEmptyObjectTypeOrSpreadsIntoEmptyObject(t); }); |
| 62874 | if (secondType) { |
| 62875 | return type; |
| 62876 | } |
| 62877 | return getAnonymousPartialType(firstType); |
| 62878 | function getAnonymousPartialType(type) { |
| 62879 | // gets the type as if it had been spread, but where everything in the spread is made optional |
| 62880 | var members = ts.createSymbolTable(); |
| 62881 | for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { |
| 62882 | var prop = _a[_i]; |
| 62883 | if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { |
| 62884 | // do nothing, skip privates |
| 62885 | } |
| 62886 | else if (isSpreadableProperty(prop)) { |
| 62887 | var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); |
| 62888 | var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; |
| 62889 | var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); |
| 62890 | result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); |
| 62891 | result.declarations = prop.declarations; |
| 62892 | result.nameType = getSymbolLinks(prop).nameType; |
| 62893 | result.syntheticOrigin = prop; |
| 62894 | members.set(prop.escapedName, result); |
| 62895 | } |
| 62896 | } |
| 62897 | var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); |
| 62898 | spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; |
| 62899 | return spread; |
| 62900 | } |
| 62901 | } |
| 62902 | /** |
| 62903 | * Since the source of spread types are object literals, which are not binary, |
| 62904 | * this function should be called in a left folding style, with left = previous result of getSpreadType |
no test coverage detected
searching dependent graphs…