fix(40685): fix generating docs for arrow functions (#40728)

This commit is contained in:
Alex T 2020-10-06 17:50:08 +03:00 committed by GitHub
parent 66c877f57a
commit 1e49ad8370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -329,6 +329,7 @@ namespace ts.JsDoc {
case SyntaxKind.MethodDeclaration:
case SyntaxKind.Constructor:
case SyntaxKind.MethodSignature:
case SyntaxKind.ArrowFunction:
const { parameters } = commentOwner as FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | MethodSignature;
return { commentOwner, parameters };

View File

@ -8,10 +8,15 @@ const multiLineOffset = 12;
//// foo() {
//// return undefined;
//// }
////
//// /*1*/
//// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { }
////
//// /*2*/
//// m: function(a) {}
//// m1: function(a) {}
////
//// /*3*/
//// m2: (a: string, b: string) => {}
////}
verify.docCommentTemplateAt("0", singleLineOffset, "/** */");
@ -23,9 +28,16 @@ verify.docCommentTemplateAt("1", multiLineOffset,
* @param y
* @param z
*/`);
verify.docCommentTemplateAt("2", multiLineOffset,
`/**
*
* @param a
*/`);
verify.docCommentTemplateAt("3", multiLineOffset,
`/**
*
* @param a
* @param b
*/`);