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

Function getSignatureFromDeclaration

test/fixtures/snapshot/typescript.js:59621–59695  ·  view source on GitHub ↗
(declaration)

Source from the content-addressed store, hash-verified

59619 return typeArguments && typeArguments.slice();
59620 }
59621 function getSignatureFromDeclaration(declaration) {
59622 var links = getNodeLinks(declaration);
59623 if (!links.resolvedSignature) {
59624 var parameters = [];
59625 var flags = 0 /* SignatureFlags.None */;
59626 var minArgumentCount = 0;
59627 var thisParameter = void 0;
59628 var hasThisParameter = false;
59629 var iife = ts.getImmediatelyInvokedFunctionExpression(declaration);
59630 var isJSConstructSignature = ts.isJSDocConstructSignature(declaration);
59631 var isUntypedSignatureInJSFile = !iife &&
59632 ts.isInJSFile(declaration) &&
59633 ts.isValueSignatureDeclaration(declaration) &&
59634 !ts.hasJSDocParameterTags(declaration) &&
59635 !ts.getJSDocType(declaration);
59636 if (isUntypedSignatureInJSFile) {
59637 flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */;
59638 }
59639 // If this is a JSDoc construct signature, then skip the first parameter in the
59640 // parameter list. The first parameter represents the return type of the construct
59641 // signature.
59642 for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
59643 var param = declaration.parameters[i];
59644 var paramSymbol = param.symbol;
59645 var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
59646 // Include parameter symbol instead of property symbol in the signature
59647 if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) {
59648 var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false);
59649 paramSymbol = resolvedSymbol;
59650 }
59651 if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) {
59652 hasThisParameter = true;
59653 thisParameter = param.symbol;
59654 }
59655 else {
59656 parameters.push(paramSymbol);
59657 }
59658 if (type && type.kind === 196 /* SyntaxKind.LiteralType */) {
59659 flags |= 2 /* SignatureFlags.HasLiteralTypes */;
59660 }
59661 // Record a new minimum argument count if this is not an optional parameter
59662 var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) ||
59663 param.initializer || param.questionToken || ts.isRestParameter(param) ||
59664 iife && parameters.length > iife.arguments.length && !type ||
59665 isJSDocOptionalParameter(param);
59666 if (!isOptionalParameter_1) {
59667 minArgumentCount = parameters.length;
59668 }
59669 }
59670 // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation
59671 if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) &&
59672 hasBindableName(declaration) &&
59673 (!hasThisParameter || !thisParameter)) {
59674 var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */;
59675 var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind);
59676 if (other) {
59677 thisParameter = getAnnotatedAccessorThisParameter(other);
59678 }

Calls 13

getNodeLinksFunction · 0.85
resolveNameFunction · 0.85
isJSDocOptionalParameterFunction · 0.85
hasBindableNameFunction · 0.85
getSymbolOfNodeFunction · 0.85
getMergedSymbolFunction · 0.85
createSignatureFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…