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

Function combineIntersectionParameters

test/fixtures/snapshot/typescript.js:73200–73240  ·  view source on GitHub ↗
(left, right, mapper)

Source from the content-addressed store, hash-verified

73198 return createSymbolWithType(left, thisType);
73199 }
73200 function combineIntersectionParameters(left, right, mapper) {
73201 var leftCount = getParameterCount(left);
73202 var rightCount = getParameterCount(right);
73203 var longest = leftCount >= rightCount ? left : right;
73204 var shorter = longest === left ? right : left;
73205 var longestCount = longest === left ? leftCount : rightCount;
73206 var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right));
73207 var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest);
73208 var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0));
73209 for (var i = 0; i < longestCount; i++) {
73210 var longestParamType = tryGetTypeAtPosition(longest, i);
73211 if (longest === right) {
73212 longestParamType = instantiateType(longestParamType, mapper);
73213 }
73214 var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType;
73215 if (shorter === right) {
73216 shorterParamType = instantiateType(shorterParamType, mapper);
73217 }
73218 var unionParamType = getUnionType([longestParamType, shorterParamType]);
73219 var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1);
73220 var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter);
73221 var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i);
73222 var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i);
73223 var paramName = leftName === rightName ? leftName :
73224 !leftName ? rightName :
73225 !rightName ? leftName :
73226 undefined;
73227 var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i));
73228 paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
73229 params[i] = paramSymbol;
73230 }
73231 if (needsExtraRestElement) {
73232 var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args");
73233 restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount));
73234 if (shorter === right) {
73235 restParamSymbol.type = instantiateType(restParamSymbol.type, mapper);
73236 }
73237 params[longestCount] = restParamSymbol;
73238 }
73239 return params;
73240 }
73241 function combineSignaturesOfIntersectionMembers(left, right) {
73242 var typeParams = left.typeParameters || right.typeParameters;
73243 var paramMapper;

Calls 11

getParameterCountFunction · 0.85
tryGetTypeAtPositionFunction · 0.85
instantiateTypeFunction · 0.85
getUnionTypeFunction · 0.85
getMinArgumentCountFunction · 0.85
createSymbolFunction · 0.85
createArrayTypeFunction · 0.85
getTypeAtPositionFunction · 0.85
concatMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…