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

Function mapType

test/fixtures/snapshot/typescript.js:69921–69946  ·  view source on GitHub ↗
(type, mapper, noReductions)

Source from the content-addressed store, hash-verified

69919 return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1;
69920 }
69921 function mapType(type, mapper, noReductions) {
69922 if (type.flags & 131072 /* TypeFlags.Never */) {
69923 return type;
69924 }
69925 if (!(type.flags & 1048576 /* TypeFlags.Union */)) {
69926 return mapper(type);
69927 }
69928 var origin = type.origin;
69929 var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types;
69930 var mappedTypes;
69931 var changed = false;
69932 for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
69933 var t = types_17[_i];
69934 var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t);
69935 changed || (changed = t !== mapped);
69936 if (mapped) {
69937 if (!mappedTypes) {
69938 mappedTypes = [mapped];
69939 }
69940 else {
69941 mappedTypes.push(mapped);
69942 }
69943 }
69944 }
69945 return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type;
69946 }
69947 function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
69948 return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ?
69949 getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) :

Callers 15

getRestTypeFunction · 0.85
getNonUndefinedTypeFunction · 0.85
getLowerBoundOfKeyTypeFunction · 0.85
getTemplateLiteralTypeFunction · 0.85
getStringMappingTypeFunction · 0.85
getSpreadTypeFunction · 0.85
getTupleElementTypeFunction · 0.85

Calls 3

getUnionTypeFunction · 0.85
mapperFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected