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

Function getContextualSignature

test/fixtures/snapshot/typescript.js:73294–73331  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

73292 // all identical ignoring their return type, the result is same signature but with return type as
73293 // union type of return types from these signatures
73294 function getContextualSignature(node) {
73295 ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node));
73296 var typeTagSignature = getSignatureOfTypeTag(node);
73297 if (typeTagSignature) {
73298 return typeTagSignature;
73299 }
73300 var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */);
73301 if (!type) {
73302 return undefined;
73303 }
73304 if (!(type.flags & 1048576 /* TypeFlags.Union */)) {
73305 return getContextualCallSignature(type, node);
73306 }
73307 var signatureList;
73308 var types = type.types;
73309 for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
73310 var current = types_19[_i];
73311 var signature = getContextualCallSignature(current, node);
73312 if (signature) {
73313 if (!signatureList) {
73314 // This signature will contribute to contextual union signature
73315 signatureList = [signature];
73316 }
73317 else if (!compareSignaturesIdentical(signatureList[0], signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true, compareTypesIdentical)) {
73318 // Signatures aren't identical, do not use
73319 return undefined;
73320 }
73321 else {
73322 // Use this signature for contextual union signature
73323 signatureList.push(signature);
73324 }
73325 }
73326 }
73327 // Result is union of signatures collected (return type is union of return types of this signature set)
73328 if (signatureList) {
73329 return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
73330 }
73331 }
73332 function checkSpreadExpression(node, checkMode) {
73333 if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
73334 checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */);

Calls 7

getSignatureOfTypeTagFunction · 0.85
createUnionSignatureFunction · 0.85
assertMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…