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

Function getContextualTypeForArgumentAtIndex

test/fixtures/snapshot/typescript.js:72584–72600  ·  view source on GitHub ↗
(callTarget, argIndex)

Source from the content-addressed store, hash-verified

72582 return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex);
72583 }
72584 function getContextualTypeForArgumentAtIndex(callTarget, argIndex) {
72585 if (ts.isImportCall(callTarget)) {
72586 return argIndex === 0 ? stringType :
72587 argIndex === 1 ? getGlobalImportCallOptionsType(/*reportErrors*/ false) :
72588 anyType;
72589 }
72590 // If we're already in the process of resolving the given signature, don't resolve again as
72591 // that could cause infinite recursion. Instead, return anySignature.
72592 var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget);
72593 if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) {
72594 return getEffectiveFirstArgumentForJsxSignature(signature, callTarget);
72595 }
72596 var restIndex = signature.parameters.length - 1;
72597 return signatureHasRestParameter(signature) && argIndex >= restIndex ?
72598 getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) :
72599 getTypeAtPosition(signature, argIndex);
72600 }
72601 function getContextualTypeForSubstitutionExpression(template, substitutionExpression) {
72602 if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) {
72603 return getContextualTypeForArgument(template.parent, substitutionExpression);

Callers 3

createTypeCheckerFunction · 0.85

Calls 9

getNodeLinksFunction · 0.85
getResolvedSignatureFunction · 0.85
getIndexedAccessTypeFunction · 0.85
getTypeOfSymbolFunction · 0.85
getNumberLiteralTypeFunction · 0.85
getTypeAtPositionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…