Support property declarations in jsdoc template generation (#36658)

* Support property declarations in jsdoc template generation

* fix lint and add test
This commit is contained in:
Nathan Shively-Sanders
2020-02-06 14:38:21 -08:00
committed by GitHub
parent b8b59489e1
commit 2cc585668d
2 changed files with 44 additions and 1 deletions

View File

@@ -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 };
}
}
}