File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
tests/cases/fourslash/server Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -4917,6 +4917,28 @@ namespace ts {
4917
4917
4918
4918
if ( ! documentation ) {
4919
4919
documentation = symbol . getDocumentationComment ( ) ;
4920
+ if ( documentation . length === 0 && symbol . flags & SymbolFlags . Property ) {
4921
+ // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo`
4922
+ // there documentation comments might be attached to the right hand side symbol of their declarations.
4923
+ // The pattern of such special property access is that the parent symbol is the symbol of the file.
4924
+ if ( symbol . parent && forEach ( symbol . parent . declarations , declaration => declaration . kind === SyntaxKind . SourceFile ) ) {
4925
+ for ( const declaration of symbol . declarations ) {
4926
+ if ( ! declaration . parent || declaration . parent . kind !== SyntaxKind . BinaryExpression ) {
4927
+ continue ;
4928
+ }
4929
+
4930
+ const rhsSymbol = program . getTypeChecker ( ) . getSymbolAtLocation ( ( < BinaryExpression > declaration . parent ) . right ) ;
4931
+ if ( ! rhsSymbol ) {
4932
+ continue ;
4933
+ }
4934
+
4935
+ documentation = rhsSymbol . getDocumentationComment ( ) ;
4936
+ if ( documentation . length > 0 ) {
4937
+ break ;
4938
+ }
4939
+ }
4940
+ }
4941
+ }
4920
4942
}
4921
4943
4922
4944
return { displayParts, documentation, symbolKind } ;
Original file line number Diff line number Diff line change
1
+ /// <reference path="../fourslash.ts"/>
2
+
3
+ // @allowNonTsExtensions : true
4
+ // @Filename : a.js
5
+ //// /**
6
+ //// * Modify the parameter
7
+ //// * @param {string } p1
8
+ //// */
9
+ //// var foo = function (p1) { }
10
+ //// exports.foo = foo;
11
+ //// fo/*1*/
12
+
13
+ // @Filename : b.ts
14
+ //// import a = require("./a");
15
+ //// a.fo/*2*/
16
+
17
+ goTo . marker ( '1' ) ;
18
+ verify . completionEntryDetailIs ( "foo" , "var foo: (p1: string) => void" , "Modify the parameter" ) ;
19
+ goTo . marker ( '2' ) ;
20
+ verify . completionEntryDetailIs ( "foo" , "(property) a.foo: (p1: string) => void" , "Modify the parameter" ) ;
You can’t perform that action at this time.
0 commit comments