goto-def should treat constructor functions as functions (#33109)

* goto-def:special handling for constructor functions

* Just treat constructor functions like functions

* Even simpler fallback
This commit is contained in:
Nathan Shively-Sanders
2019-08-27 16:22:22 -07:00
committed by GitHub
parent 4fc12d7b03
commit 13e1ccdd01
2 changed files with 16 additions and 1 deletions

View File

@@ -241,7 +241,7 @@ namespace ts.GoToDefinition {
function getConstructSignatureDefinition(): DefinitionInfo[] | undefined {
// Applicable only if we are in a new expression, or we are on a constructor declaration
// and in either case the symbol has a construct signature definition, i.e. class
if (symbol.flags & SymbolFlags.Class && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) {
if (symbol.flags & SymbolFlags.Class && !(symbol.flags & SymbolFlags.Function) && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) {
const cls = find(filteredDeclarations, isClassLike) || Debug.fail("Expected declaration to have at least one class-like declaration");
return getSignatureDefinition(cls.members, /*selectConstructors*/ true);
}