@@ -26,10 +26,21 @@ namespace ts.GoToDefinition {
2626 return label ? [ createDefinitionInfoFromName ( typeChecker , label , ScriptElementKind . label , node . text , /*containerName*/ undefined ! ) ] : undefined ; // TODO: GH#18217
2727 }
2828
29- if ( node . kind === SyntaxKind . ReturnKeyword ) {
30- const functionDeclaration = findAncestor ( node . parent , n =>
31- isClassStaticBlockDeclaration ( n ) ? "quit" : isFunctionLikeDeclaration ( n ) ) as FunctionLikeDeclaration | undefined ;
32- return functionDeclaration ? [ createDefinitionFromSignatureDeclaration ( typeChecker , functionDeclaration ) ] : undefined ;
29+ switch ( node . kind ) {
30+ case SyntaxKind . ReturnKeyword :
31+ const functionDeclaration = findAncestor ( node . parent , n =>
32+ isClassStaticBlockDeclaration ( n ) ? "quit" : isFunctionLikeDeclaration ( n ) ) as FunctionLikeDeclaration | undefined ;
33+ return functionDeclaration ? [ createDefinitionFromSignatureDeclaration ( typeChecker , functionDeclaration ) ] : undefined ;
34+ case SyntaxKind . DefaultKeyword :
35+ if ( ! isDefaultClause ( node . parent ) ) {
36+ break ;
37+ }
38+ case SyntaxKind . CaseKeyword :
39+ const switchStatement = findAncestor ( node . parent , isSwitchStatement ) ;
40+ if ( switchStatement ) {
41+ return [ createDefinitionInfoFromNode ( switchStatement , "switch" ) ] ;
42+ }
43+ break ;
3344 }
3445
3546 if ( isStaticModifier ( node ) && isClassStaticBlockDeclaration ( node . parent ) ) {
@@ -510,4 +521,21 @@ namespace ts.GoToDefinition {
510521 return false ;
511522 }
512523 }
524+
525+ function createDefinitionInfoFromNode ( node : Node , name : string ) : DefinitionInfo {
526+ const sourceFile = node . getSourceFile ( ) ;
527+ return {
528+ fileName : sourceFile . fileName ,
529+ textSpan : createTextSpanFromNode ( node , sourceFile ) ,
530+ kind : ScriptElementKind . label ,
531+ name,
532+ containerKind : ScriptElementKind . unknown ,
533+ containerName : "" ,
534+ contextSpan : createTextSpanFromNode ( node , sourceFile ) ,
535+ isLocal : false ,
536+ isAmbient : false ,
537+ unverified : false ,
538+ failedAliasResolution : undefined ,
539+ } ;
540+ }
513541}
0 commit comments