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

Function mappedTypeRelatedTo

test/fixtures/snapshot/typescript.js:66188–66203  ·  view source on GitHub ↗
(source, target, reportErrors)

Source from the content-addressed store, hash-verified

66186 // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice
66187 // that S and T are contra-variant whereas X and Y are co-variant.
66188 function mappedTypeRelatedTo(source, target, reportErrors) {
66189 var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
66190 getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
66191 if (modifiersRelated) {
66192 var result_10;
66193 var targetConstraint = getConstraintTypeFromMappedType(target);
66194 var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
66195 if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) {
66196 var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
66197 if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
66198 return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors);
66199 }
66200 }
66201 }
66202 return 0 /* Ternary.False */;
66203 }
66204 function typeRelatedToDiscriminatedType(source, target) {
66205 // 1. Generate the combinations of discriminant properties & types 'source' can satisfy.
66206 // a. If the number of combinations is above a set limit, the comparison is too complex.

Callers 1

structuredTypeRelatedToFunction · 0.85

Calls 10

getMappedTypeModifiersFunction · 0.85
instantiateTypeFunction · 0.85
makeFunctionTypeMapperFunction · 0.85
isRelatedToFunction · 0.85
createTypeMapperFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…