@@ -399,23 +399,40 @@ namespace ts.FindAllReferences {
399399 function getPrefixAndSuffixText ( entry : Entry , originalNode : Node , checker : TypeChecker ) : PrefixAndSuffix {
400400 if ( entry . kind !== EntryKind . Span && isIdentifier ( originalNode ) ) {
401401 const { node, kind } = entry ;
402+ const parent = node . parent ;
402403 const name = originalNode . text ;
403- const isShorthandAssignment = isShorthandPropertyAssignment ( node . parent ) ;
404- if ( isShorthandAssignment || isObjectBindingElementWithoutPropertyName ( node . parent ) && node . parent . name === node ) {
404+ const isShorthandAssignment = isShorthandPropertyAssignment ( parent ) ;
405+ if ( isShorthandAssignment || isObjectBindingElementWithoutPropertyName ( parent ) && parent . name === node ) {
405406 const prefixColon : PrefixAndSuffix = { prefixText : name + ": " } ;
406407 const suffixColon : PrefixAndSuffix = { suffixText : ": " + name } ;
407- return kind === EntryKind . SearchedLocalFoundProperty ? prefixColon
408- : kind === EntryKind . SearchedPropertyFoundLocal ? suffixColon
409- // In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol.
410- // For a binding element `const { x } = o;`, symbolAtLocation at `x` is the property symbol.
411- : isShorthandAssignment ? suffixColon : prefixColon ;
408+ if ( kind === EntryKind . SearchedLocalFoundProperty ) {
409+ return prefixColon ;
410+ }
411+ if ( kind === EntryKind . SearchedPropertyFoundLocal ) {
412+ return suffixColon ;
413+ }
414+
415+ // In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol.
416+ // For a binding element `const { x } = o;`, symbolAtLocation at `x` is the property symbol.
417+ if ( isShorthandAssignment ) {
418+ const grandParent = parent . parent ;
419+ if ( isObjectLiteralExpression ( grandParent ) &&
420+ isBinaryExpression ( grandParent . parent ) &&
421+ isModuleExportsAccessExpression ( grandParent . parent . left ) ) {
422+ return prefixColon ;
423+ }
424+ return suffixColon ;
425+ }
426+ else {
427+ return prefixColon ;
428+ }
412429 }
413- else if ( isImportSpecifier ( entry . node . parent ) && ! entry . node . parent . propertyName ) {
430+ else if ( isImportSpecifier ( parent ) && ! parent . propertyName ) {
414431 // If the original symbol was using this alias, just rename the alias.
415432 const originalSymbol = isExportSpecifier ( originalNode . parent ) ? checker . getExportSpecifierLocalTargetSymbol ( originalNode . parent ) : checker . getSymbolAtLocation ( originalNode ) ;
416- return contains ( originalSymbol ! . declarations , entry . node . parent ) ? { prefixText : name + " as " } : emptyOptions ;
433+ return contains ( originalSymbol ! . declarations , parent ) ? { prefixText : name + " as " } : emptyOptions ;
417434 }
418- else if ( isExportSpecifier ( entry . node . parent ) && ! entry . node . parent . propertyName ) {
435+ else if ( isExportSpecifier ( parent ) && ! parent . propertyName ) {
419436 // If the symbol for the node is same as declared node symbol use prefix text
420437 return originalNode === entry . node || checker . getSymbolAtLocation ( originalNode ) === checker . getSymbolAtLocation ( entry . node ) ?
421438 { prefixText : name + " as " } :
0 commit comments