File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ namespace ts.GoToDefinition {
29
29
30
30
const calledDeclaration = tryGetSignatureDeclaration ( typeChecker , node ) ;
31
31
// Don't go to the component constructor definition for a JSX element, just go to the component definition.
32
- if ( calledDeclaration && ! ( isJsxOpeningLikeElement ( node . parent ) && isConstructorDeclaration ( calledDeclaration ) ) ) {
32
+ if ( calledDeclaration && ! ( isJsxOpeningLikeElement ( node . parent ) && isConstructorLike ( calledDeclaration ) ) ) {
33
33
const sigInfo = createDefinitionFromSignatureDeclaration ( typeChecker , calledDeclaration ) ;
34
34
// For a function, if this is the original function definition, return just sigInfo.
35
35
// If this is the original constructor definition, parent is the class.
@@ -319,4 +319,15 @@ namespace ts.GoToDefinition {
319
319
// Don't go to a function type, go to the value having that type.
320
320
return tryCast ( signature && signature . declaration , ( d ) : d is SignatureDeclaration => isFunctionLike ( d ) && ! isFunctionTypeNode ( d ) ) ;
321
321
}
322
+
323
+ function isConstructorLike ( node : Node ) : boolean {
324
+ switch ( node . kind ) {
325
+ case SyntaxKind . Constructor :
326
+ case SyntaxKind . ConstructorType :
327
+ case SyntaxKind . ConstructSignature :
328
+ return true ;
329
+ default :
330
+ return false ;
331
+ }
332
+ }
322
333
}
Original file line number Diff line number Diff line change 21
21
////o.[|/*useM*/m|]();
22
22
23
23
////class Component { /*componentCtr*/constructor(props: {}) {} }
24
+ ////type ComponentClass = /*ComponentClass*/new () => Component;
25
+ ////interface ComponentClass2 { /*ComponentClass2*/new(): Component; }
26
+ ////
24
27
////class /*MyComponent*/MyComponent extends Component {}
25
- ////<[|/*jsxMyComponent*/MyComponent|] />
28
+ ////<[|/*jsxMyComponent*/MyComponent|] />;
26
29
////new [|/*newMyComponent*/MyComponent|]({});
30
+ ////
31
+ ////declare const /*MyComponent2*/MyComponent2: ComponentClass;
32
+ ////<[|/*jsxMyComponent2*/MyComponent2|] />;
33
+ ////new [|/*newMyComponent2*/MyComponent2|]();
34
+ ////
35
+ ////declare const /*MyComponent3*/MyComponent3: ComponentClass2;
36
+ ////<[|/*jsxMyComponent3*/MyComponent3|] />;
37
+ ////new [|/*newMyComponent3*/MyComponent3|]();
27
38
28
39
verify . noErrors ( ) ;
29
40
@@ -38,4 +49,10 @@ verify.goToDefinition({
38
49
39
50
jsxMyComponent : "MyComponent" ,
40
51
newMyComponent : [ "MyComponent" , "componentCtr" ] ,
52
+
53
+ jsxMyComponent2 : "MyComponent2" ,
54
+ newMyComponent2 : [ "MyComponent2" , "ComponentClass" ] ,
55
+
56
+ jsxMyComponent3 : "MyComponent3" ,
57
+ newMyComponent3 : [ "MyComponent3" , "ComponentClass2" ] ,
41
58
} ) ;
You can’t perform that action at this time.
0 commit comments