mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @noEmit: true
|
||||
// @filename: gotoDefinitionConstructorFunction.js
|
||||
//// function /*end*/StringStreamm() {
|
||||
//// }
|
||||
//// StringStreamm.prototype = {
|
||||
//// };
|
||||
////
|
||||
//// function runMode () {
|
||||
//// new [|/*start*/StringStreamm|]()
|
||||
//// };
|
||||
|
||||
verify.goToDefinition('start', 'end')
|
||||
Reference in New Issue
Block a user