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

Function compareTypeParametersIdentical

test/fixtures/snapshot/typescript.js:58159–58181  ·  view source on GitHub ↗
(sourceParams, targetParams)

Source from the content-addressed store, hash-verified

58157 return result || ts.emptyArray;
58158 }
58159 function compareTypeParametersIdentical(sourceParams, targetParams) {
58160 if (ts.length(sourceParams) !== ts.length(targetParams)) {
58161 return false;
58162 }
58163 if (!sourceParams || !targetParams) {
58164 return true;
58165 }
58166 var mapper = createTypeMapper(targetParams, sourceParams);
58167 for (var i = 0; i < sourceParams.length; i++) {
58168 var source = sourceParams[i];
58169 var target = targetParams[i];
58170 if (source === target)
58171 continue;
58172 // We instantiate the target type parameter constraints into the source types so we can recognize `<T, U extends T>` as the same as `<A, B extends A>`
58173 if (!isTypeIdenticalTo(getConstraintFromTypeParameter(source) || unknownType, instantiateType(getConstraintFromTypeParameter(target) || unknownType, mapper)))
58174 return false;
58175 // We don't compare defaults - we just use the type parameter defaults from the first signature that seems to match.
58176 // It might make sense to combine these defaults in the future, but doing so intelligently requires knowing
58177 // if the parameter is used covariantly or contravariantly (so we intersect if it's used like a parameter or union if used like a return type)
58178 // and, since it's just an inference _default_, just picking one arbitrarily works OK.
58179 }
58180 return true;
58181 }
58182 function combineUnionThisParam(left, right, mapper) {
58183 if (!left || !right) {
58184 return left || right;

Callers 2

_loop_10Function · 0.85
getIntersectedSignaturesFunction · 0.85

Calls 5

createTypeMapperFunction · 0.85
isTypeIdenticalToFunction · 0.85
instantiateTypeFunction · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…