MCPcopy Create free account
hub / github.com/nodejs/node / isAritySmaller

Function isAritySmaller

test/fixtures/snapshot/typescript.js:73270–73282  ·  view source on GitHub ↗

If the contextual signature has fewer parameters than the function expression, do not use it

(signature, target)

Source from the content-addressed store, hash-verified

73268 }
73269 /** If the contextual signature has fewer parameters than the function expression, do not use it */
73270 function isAritySmaller(signature, target) {
73271 var targetParameterCount = 0;
73272 for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
73273 var param = target.parameters[targetParameterCount];
73274 if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
73275 break;
73276 }
73277 }
73278 if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
73279 targetParameterCount--;
73280 }
73281 return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
73282 }
73283 function getContextualSignatureForFunctionLikeDeclaration(node) {
73284 // Only function expressions, arrow functions, and object literal methods are contextually typed.
73285 return ts.isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)

Callers 1

Calls 3

isJSDocOptionalParameterFunction · 0.85
getParameterCountFunction · 0.85

Tested by

no test coverage detected