File tree 2 files changed +29
-2
lines changed
2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -439,12 +439,18 @@ namespace ts.JsDoc {
439
439
440
440
case SyntaxKind . ClassDeclaration :
441
441
case SyntaxKind . InterfaceDeclaration :
442
- case SyntaxKind . PropertySignature :
443
442
case SyntaxKind . EnumDeclaration :
444
443
case SyntaxKind . EnumMember :
445
444
case SyntaxKind . TypeAliasDeclaration :
446
445
return { commentOwner } ;
447
446
447
+ case SyntaxKind . PropertySignature : {
448
+ const host = commentOwner as PropertySignature ;
449
+ return host . type && isFunctionTypeNode ( host . type )
450
+ ? { commentOwner, parameters : host . type . parameters , hasReturn : hasReturn ( host . type , options ) }
451
+ : { commentOwner } ;
452
+ }
453
+
448
454
case SyntaxKind . VariableStatement : {
449
455
const varStatement = commentOwner as VariableStatement ;
450
456
const varDeclarations = varStatement . declarationList . declarations ;
@@ -486,7 +492,7 @@ namespace ts.JsDoc {
486
492
487
493
function hasReturn ( node : Node , options : DocCommentTemplateOptions | undefined ) {
488
494
return ! ! options ?. generateReturnInDocTemplate &&
489
- ( isArrowFunction ( node ) && isExpression ( node . body )
495
+ ( isFunctionTypeNode ( node ) || isArrowFunction ( node ) && isExpression ( node . body )
490
496
|| isFunctionLikeDeclaration ( node ) && node . body && isBlock ( node . body ) && ! ! forEachReturnStatement ( node . body , n => n ) ) ;
491
497
}
492
498
Original file line number Diff line number Diff line change
1
+ /// <reference path="fourslash.ts" />
2
+
3
+ ////interface I {
4
+ //// /**/
5
+ //// foo: (a: number, b: string) => void;
6
+ //// }
7
+
8
+ verify . docCommentTemplateAt ( "" , 12 ,
9
+ `/**
10
+ *
11
+ * @param a
12
+ * @param b
13
+ * @returns
14
+ */` ) ;
15
+
16
+ verify . docCommentTemplateAt ( "" , 12 ,
17
+ `/**
18
+ *
19
+ * @param a
20
+ * @param b
21
+ */` , { generateReturnInDocTemplate : false } ) ;
You can’t perform that action at this time.
0 commit comments