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

Function replacePrimitivesWithLiterals

test/fixtures/snapshot/typescript.js:69960–69971  ·  view source on GitHub ↗
(typeWithPrimitives, typeWithLiterals)

Source from the content-addressed store, hash-verified

69958 // true intersection because it is more costly and, when applied to union types, generates a large number of
69959 // types we don't actually care about.
69960 function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
69961 if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) &&
69962 maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) {
69963 return mapType(typeWithPrimitives, function (t) {
69964 return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) :
69965 isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) :
69966 t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) :
69967 t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t;
69968 });
69969 }
69970 return typeWithPrimitives;
69971 }
69972 function isIncomplete(flowType) {
69973 return flowType.flags === 0;
69974 }

Callers 2

narrowTypeByEqualityFunction · 0.85

Calls 4

maybeTypeOfKindFunction · 0.85
mapTypeFunction · 0.85
extractTypesOfKindFunction · 0.85
isPatternLiteralTypeFunction · 0.85

Tested by

no test coverage detected