diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 56e0a0ae50ed6..995561c016b7d 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -251,7 +251,6 @@ namespace ts.JsDoc { * @param position The (character-indexed) position in the file where the check should * be performed. */ - export function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number): TextInsertion | undefined { const tokenAtPos = getTokenAtPosition(sourceFile, position); const existingDocComment = findAncestor(tokenAtPos, isJSDoc); @@ -370,6 +369,11 @@ namespace ts.JsDoc { const parameters = isFunctionLike(be.right) ? be.right.parameters : emptyArray; return { commentOwner, parameters }; } + case SyntaxKind.PropertyDeclaration: + const init = (commentOwner as PropertyDeclaration).initializer; + if (init && (isFunctionExpression(init) || isArrowFunction(init))) { + return { commentOwner, parameters: init.parameters }; + } } } diff --git a/tests/cases/fourslash/docCommentTemplateClassDeclProperty01.ts b/tests/cases/fourslash/docCommentTemplateClassDeclProperty01.ts new file mode 100644 index 0000000000000..ee235f34cec3b --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateClassDeclProperty01.ts @@ -0,0 +1,39 @@ +/// + +const singleLineOffset = 3; +const multiLineOffset = 12; + + +////class C { +//// /** /*0*/ */ +//// foo = (p0) => { +//// return p0; +//// }; +//// /*1*/ +//// bar = (p1) => { +//// return p1; +//// } +//// /*2*/ +//// baz = function (p2, p3) { +//// return p2; +//// } +////} + +verify.docCommentTemplateAt("0", multiLineOffset, + `/** + * + * @param p0 + */`); +verify.docCommentTemplateAt("1", multiLineOffset, + `/** + * + * @param p1 + */`); +verify.docCommentTemplateAt("2", multiLineOffset, + `/** + * + * @param p2 + * @param p3 + */`); + +