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

Function getConditionalTypeInstantiation

test/fixtures/snapshot/typescript.js:63603–63627  ·  view source on GitHub ↗
(type, mapper, aliasSymbol, aliasTypeArguments)

Source from the content-addressed store, hash-verified

63601 return result;
63602 }
63603 function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
63604 var root = type.root;
63605 if (root.outerTypeParameters) {
63606 // We are instantiating a conditional type that has one or more type parameters in scope. Apply the
63607 // mapper to the type parameters to produce the effective list of type arguments, and compute the
63608 // instantiation cache key from the type IDs of the type arguments.
63609 var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); });
63610 var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
63611 var result = root.instantiations.get(id);
63612 if (!result) {
63613 var newMapper_1 = createTypeMapper(root.outerTypeParameters, typeArguments);
63614 var checkType_1 = root.checkType;
63615 var distributionType = root.isDistributive ? getMappedType(checkType_1, newMapper_1) : undefined;
63616 // Distributive conditional types are distributed over union types. For example, when the
63617 // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the
63618 // result is (A extends U ? X : Y) | (B extends U ? X : Y).
63619 result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ?
63620 mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) :
63621 getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments);
63622 root.instantiations.set(id, result);
63623 }
63624 return result;
63625 }
63626 return type;
63627 }
63628 function instantiateType(type, mapper) {
63629 return type && mapper ? instantiateTypeWithAlias(type, mapper, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined) : type;
63630 }

Callers 3

getLowerBoundOfKeyTypeFunction · 0.85
instantiateTypeWorkerFunction · 0.85

Calls 11

getMappedTypeFunction · 0.85
getTypeListIdFunction · 0.85
getAliasIdFunction · 0.85
createTypeMapperFunction · 0.85
mapTypeWithAliasFunction · 0.85
getReducedTypeFunction · 0.85
getConditionalTypeFunction · 0.85
prependTypeMappingFunction · 0.85
mapMethod · 0.65
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected