File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -251,7 +251,6 @@ namespace ts.JsDoc {
251251 * @param position The (character-indexed) position in the file where the check should
252252 * be performed.
253253 */
254-
255254 export function getDocCommentTemplateAtPosition ( newLine : string , sourceFile : SourceFile , position : number ) : TextInsertion | undefined {
256255 const tokenAtPos = getTokenAtPosition ( sourceFile , position ) ;
257256 const existingDocComment = findAncestor ( tokenAtPos , isJSDoc ) ;
@@ -370,6 +369,11 @@ namespace ts.JsDoc {
370369 const parameters = isFunctionLike ( be . right ) ? be . right . parameters : emptyArray ;
371370 return { commentOwner, parameters } ;
372371 }
372+ case SyntaxKind . PropertyDeclaration :
373+ const init = ( commentOwner as PropertyDeclaration ) . initializer ;
374+ if ( init && ( isFunctionExpression ( init ) || isArrowFunction ( init ) ) ) {
375+ return { commentOwner, parameters : init . parameters } ;
376+ }
373377 }
374378 }
375379
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts' />
2+
3+ const singleLineOffset = 3 ;
4+ const multiLineOffset = 12 ;
5+
6+
7+ ////class C {
8+ //// /** /*0*/ */
9+ //// foo = (p0) => {
10+ //// return p0;
11+ //// };
12+ //// /*1*/
13+ //// bar = (p1) => {
14+ //// return p1;
15+ //// }
16+ //// /*2*/
17+ //// baz = function (p2, p3) {
18+ //// return p2;
19+ //// }
20+ //// }
21+
22+ verify . docCommentTemplateAt ( "0" , multiLineOffset ,
23+ `/**
24+ *
25+ * @param p0
26+ */` ) ;
27+ verify . docCommentTemplateAt ( "1" , multiLineOffset ,
28+ `/**
29+ *
30+ * @param p1
31+ */` ) ;
32+ verify . docCommentTemplateAt ( "2" , multiLineOffset ,
33+ `/**
34+ *
35+ * @param p2
36+ * @param p3
37+ */` ) ;
38+
39+
You can’t perform that action at this time.
0 commit comments