MCPcopy Create free account
hub / github.com/nodejs/node / formatUnionTypes

Function formatUnionTypes

test/fixtures/snapshot/typescript.js:55353–55379  ·  view source on GitHub ↗
(types)

Source from the content-addressed store, hash-verified

55351 }
55352 }
55353 function formatUnionTypes(types) {
55354 var result = [];
55355 var flags = 0;
55356 for (var i = 0; i < types.length; i++) {
55357 var t = types[i];
55358 flags |= t.flags;
55359 if (!(t.flags & 98304 /* TypeFlags.Nullable */)) {
55360 if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) {
55361 var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t);
55362 if (baseType.flags & 1048576 /* TypeFlags.Union */) {
55363 var count = baseType.types.length;
55364 if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
55365 result.push(baseType);
55366 i += count - 1;
55367 continue;
55368 }
55369 }
55370 }
55371 result.push(t);
55372 }
55373 }
55374 if (flags & 65536 /* TypeFlags.Null */)
55375 result.push(nullType);
55376 if (flags & 32768 /* TypeFlags.Undefined */)
55377 result.push(undefinedType);
55378 return result || types;
55379 }
55380 function visibilityToString(flags) {
55381 if (flags === 8 /* ModifierFlags.Private */) {
55382 return "private";

Callers 1

typeToTypeNodeHelperFunction · 0.85

Calls 3

pushMethod · 0.45

Tested by

no test coverage detected