Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c1b36f

Browse files
authored
fix37816: goToDefinition skips call signatures for jsx components (microsoft#57969)
1 parent9f9682c commit0c1b36f

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

‎src/services/goToDefinition.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile
225225

226226
constcalledDeclaration=tryGetSignatureDeclaration(typeChecker,node);
227227
// Don't go to the component constructor definition for a JSX element, just go to the component definition.
228-
if(calledDeclaration&&!(isJsxOpeningLikeElement(node.parent)&&isConstructorLike(calledDeclaration))){
228+
if(calledDeclaration&&!(isJsxOpeningLikeElement(node.parent)&&isJsxConstructorLike(calledDeclaration))){
229229
constsigInfo=createDefinitionFromSignatureDeclaration(typeChecker,calledDeclaration,failedAliasResolution);
230230
// For a function, if this is the original function definition, return just sigInfo.
231231
// If this is the original constructor definition, parent is the class.
@@ -741,10 +741,11 @@ function tryGetSignatureDeclaration(typeChecker: TypeChecker, node: Node): Signa
741741
returntryCast(signature&&signature.declaration,(d):d isSignatureDeclaration=>isFunctionLike(d)&&!isFunctionTypeNode(d));
742742
}
743743

744-
functionisConstructorLike(node:Node):boolean{
744+
functionisJsxConstructorLike(node:Node):boolean{
745745
switch(node.kind){
746746
caseSyntaxKind.Constructor:
747747
caseSyntaxKind.ConstructorType:
748+
caseSyntaxKind.CallSignature:
748749
caseSyntaxKind.ConstructSignature:
749750
returntrue;
750751
default:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// === goToDefinition ===
2+
// === /tests/cases/fourslash/test.tsx ===
3+
// interface FC<P = {}> {
4+
// (props: P, context?: any): string;
5+
// }
6+
//
7+
// <|const [|Thing|]: FC = (props) => <div></div>;|>
8+
// const HelloWorld = () => <Thing />;
9+
10+
// === /tests/cases/fourslash/./test.tsx ===
11+
// interface FC<P = {}> {
12+
// (props: P, context?: any): string;
13+
// }
14+
//
15+
// const Thing: FC = (props) => <div></div>;
16+
// const HelloWorld = () => </*GOTO DEF*/[|Thing|] />;
17+
18+
// === Details ===
19+
[
20+
{
21+
"kind":"const",
22+
"name":"Thing",
23+
"containerName":"",
24+
"isLocal":false,
25+
"isAmbient":false,
26+
"unverified":false,
27+
"failedAliasResolution":false
28+
}
29+
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//@filename: ./test.tsx
4+
//// interface FC<P = {}> {
5+
//// (props: P, context?: any): string;
6+
////}
7+
////
8+
//// const Thing: FC = (props) => <div></div>;
9+
//// const HelloWorld = () => <[|/**/Thing|] />;
10+
11+
verify.baselineGoToDefinition("");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp