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

Function removeRedundantLiteralTypes

test/fixtures/snapshot/typescript.js:61223–61239  ·  view source on GitHub ↗
(types, includes, reduceVoidUndefined)

Source from the content-addressed store, hash-verified

61221 return types;
61222 }
61223 function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) {
61224 var i = types.length;
61225 while (i > 0) {
61226 i--;
61227 var t = types[i];
61228 var flags = t.flags;
61229 var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ ||
61230 flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ ||
61231 flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ ||
61232 flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ ||
61233 reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ ||
61234 isFreshLiteralType(t) && containsType(types, t.regularType);
61235 if (remove) {
61236 ts.orderedRemoveItemAt(types, i);
61237 }
61238 }
61239 }
61240 function removeStringLiteralsMatchedByTemplateLiterals(types) {
61241 var templates = ts.filter(types, isPatternLiteralType);
61242 if (templates.length) {

Callers 1

getUnionTypeFunction · 0.85

Calls 2

isFreshLiteralTypeFunction · 0.85
containsTypeFunction · 0.85

Tested by

no test coverage detected