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

Function getContextuallyTypedParameterType

test/fixtures/snapshot/typescript.js:72399–72427  ·  view source on GitHub ↗
(parameter)

Source from the content-addressed store, hash-verified

72397 }
72398 // Return contextual type of parameter or undefined if no contextual type is available
72399 function getContextuallyTypedParameterType(parameter) {
72400 var func = parameter.parent;
72401 if (!isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
72402 return undefined;
72403 }
72404 var iife = ts.getImmediatelyInvokedFunctionExpression(func);
72405 if (iife && iife.arguments) {
72406 var args = getEffectiveCallArguments(iife);
72407 var indexOfParameter = func.parameters.indexOf(parameter);
72408 if (parameter.dotDotDotToken) {
72409 return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */);
72410 }
72411 var links = getNodeLinks(iife);
72412 var cached = links.resolvedSignature;
72413 links.resolvedSignature = anySignature;
72414 var type = indexOfParameter < args.length ?
72415 getWidenedLiteralType(checkExpression(args[indexOfParameter])) :
72416 parameter.initializer ? undefined : undefinedWideningType;
72417 links.resolvedSignature = cached;
72418 return type;
72419 }
72420 var contextualSignature = getContextualSignature(func);
72421 if (contextualSignature) {
72422 var index = func.parameters.indexOf(parameter) - (ts.getThisParameter(func) ? 1 : 0);
72423 return parameter.dotDotDotToken && ts.lastOrUndefined(func.parameters) === parameter ?
72424 getRestTypeAtPosition(contextualSignature, index) :
72425 tryGetTypeAtPosition(contextualSignature, index);
72426 }
72427 }
72428 function getContextualTypeForVariableLikeDeclaration(declaration) {
72429 var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
72430 if (typeNode) {

Calls 10

getSpreadArgumentTypeFunction · 0.85
getNodeLinksFunction · 0.85
getWidenedLiteralTypeFunction · 0.85
getContextualSignatureFunction · 0.85
getRestTypeAtPositionFunction · 0.85
tryGetTypeAtPositionFunction · 0.85
checkExpressionFunction · 0.70
indexOfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…