@@ -5302,13 +5302,19 @@ namespace ts {
53025302 const node = getTouchingPropertyName ( getValidSourceFile ( fileName ) , position ) ;
53035303 const typeChecker = program . getTypeChecker ( ) ;
53045304
5305+ // If invoked directly on a shorthand property assignment, then return
5306+ // the declaration of the symbol being assigned (not the symbol being assigned to).
53055307 if ( node . parent . kind === SyntaxKind . ShorthandPropertyAssignment ) {
53065308 const entry = getReferenceEntryForShorthandPropertyAssignment ( node , typeChecker ) ;
53075309 entries . push ( {
53085310 textSpan : entry . textSpan ,
53095311 fileName : entry . fileName
53105312 } ) ;
53115313 }
5314+
5315+ // For most symbols, the definition is the same as the implementation so we can just
5316+ // call "Go to Definition". This case should handle anything that is not a type
5317+ // reference to or member of an interface, class, or union/intersection type.
53125318 else if ( definitionIsImplementation ( node , typeChecker ) ) {
53135319 const definitions = getDefinitionAtPosition ( fileName , position ) ;
53145320 forEach ( definitions , ( definition : DefinitionInfo ) => {
@@ -5318,8 +5324,12 @@ namespace ts {
53185324 } ) ;
53195325 } ) ;
53205326 }
5327+
5328+ // Interfaces, classes, and unions/intersection types separate the implementation and
5329+ // definition so "Go to Definition" is not sufficient. This case handles invocations
5330+ // on type references and members of those types.
53215331 else {
5322- // Do a search for all references and filter them down to implementations only
5332+ // Perform "Find all References" and filter them down to implementations only
53235333 const result = getReferencedSymbolsForNode ( node , program . getSourceFiles ( ) , /*findInStrings*/ false , /*findInComments*/ false , /*implementations*/ true ) ;
53245334
53255335 forEach ( result , referencedSymbol => {
@@ -5362,7 +5372,8 @@ namespace ts {
53625372 return false ;
53635373 }
53645374
5365- // Also check the right hand side to see if this is a type being accessed on a namespace/module
5375+ // Also check the right hand side to see if this is a type being accessed on a namespace/module.
5376+ // For example, SomeModule.SomeType
53665377 const rightHandType = typeChecker . getTypeAtLocation ( node ) ;
53675378 return rightHandType && ! ( rightHandType . getFlags ( ) & ( TypeFlags . Class | TypeFlags . Interface | TypeFlags . UnionOrIntersection ) ) ;
53685379 }
@@ -5424,6 +5435,11 @@ namespace ts {
54245435 return isIdentifierOfClass ( node ) || isIdentifierOfEnumDeclaration ( node ) ;
54255436 }
54265437
5438+ function isFunctionDeclarationIdentifierName ( node : Identifier ) : boolean {
5439+ return node . parent . kind === SyntaxKind . FunctionDeclaration &&
5440+ ( < FunctionDeclaration > node . parent ) . name === node ;
5441+ }
5442+
54275443 function isIdentifierOfClass ( node : Identifier ) {
54285444 return ( node . parent . kind === SyntaxKind . ClassDeclaration || node . parent . kind === SyntaxKind . ClassExpression ) &&
54295445 ( < ClassLikeDeclaration > node . parent ) . name === node ;
0 commit comments