MCPcopy Index your code
hub / github.com/nodejs/node / getAnonymousPartialType

Function getAnonymousPartialType

test/fixtures/snapshot/typescript.js:62878–62900  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

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,

Calls 10

getPropertiesOfTypeFunction · 0.85
isSpreadablePropertyFunction · 0.85
createSymbolFunction · 0.85
getIsLateCheckFlagFunction · 0.85
addOptionalityFunction · 0.85
getTypeOfSymbolFunction · 0.85
getSymbolLinksFunction · 0.85
createAnonymousTypeFunction · 0.85
getIndexInfosOfTypeFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…