Skip to content

Commit 096b2b0

Browse files
author
Andy
authored
Use isFunctionLike instead of switch (microsoft#22698)
1 parent 0df92a1 commit 096b2b0

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

src/compiler/checker.ts

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6836,32 +6836,17 @@ namespace ts {
68366836
const result: Signature[] = [];
68376837
for (let i = 0; i < symbol.declarations.length; i++) {
68386838
const node = symbol.declarations[i];
6839-
switch (node.kind) {
6840-
case SyntaxKind.FunctionType:
6841-
case SyntaxKind.ConstructorType:
6842-
case SyntaxKind.FunctionDeclaration:
6843-
case SyntaxKind.MethodDeclaration:
6844-
case SyntaxKind.MethodSignature:
6845-
case SyntaxKind.Constructor:
6846-
case SyntaxKind.CallSignature:
6847-
case SyntaxKind.ConstructSignature:
6848-
case SyntaxKind.IndexSignature:
6849-
case SyntaxKind.GetAccessor:
6850-
case SyntaxKind.SetAccessor:
6851-
case SyntaxKind.FunctionExpression:
6852-
case SyntaxKind.ArrowFunction:
6853-
case SyntaxKind.JSDocFunctionType:
6854-
// Don't include signature if node is the implementation of an overloaded function. A node is considered
6855-
// an implementation node if it has a body and the previous node is of the same kind and immediately
6856-
// precedes the implementation node (i.e. has the same parent and ends where the implementation starts).
6857-
if (i > 0 && (<FunctionLikeDeclaration>node).body) {
6858-
const previous = symbol.declarations[i - 1];
6859-
if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) {
6860-
break;
6861-
}
6862-
}
6863-
result.push(getSignatureFromDeclaration(<SignatureDeclaration>node));
6839+
if (!isFunctionLike(node)) continue;
6840+
// Don't include signature if node is the implementation of an overloaded function. A node is considered
6841+
// an implementation node if it has a body and the previous node is of the same kind and immediately
6842+
// precedes the implementation node (i.e. has the same parent and ends where the implementation starts).
6843+
if (i > 0 && (node as FunctionLikeDeclaration).body) {
6844+
const previous = symbol.declarations[i - 1];
6845+
if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) {
6846+
continue;
6847+
}
68646848
}
6849+
result.push(getSignatureFromDeclaration(node));
68656850
}
68666851
return result;
68676852
}

0 commit comments

Comments
 (0)