Skip to content

Commit 05c5279

Browse files
Shannon Pooletmcw
Shannon Poole
authored andcommitted
feat: add support for class param declarations at the constructor (#1013)
1 parent 647fdf4 commit 05c5279

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/infer/params.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ function inferParams(comment: Comment) {
5252

5353
function inferAndCombineParams(params, comment) {
5454
const inferredParams = params.map((param, i) => paramToDoc(param, '', i));
55-
const mergedParamsAndErrors = mergeTrees(inferredParams, comment.params);
55+
const paramsToMerge = comment.params;
56+
if (comment.constructorComment) {
57+
paramsToMerge.push.apply(paramsToMerge, comment.constructorComment.params);
58+
}
59+
const mergedParamsAndErrors = mergeTrees(inferredParams, paramsToMerge);
5660

5761
// Then merge the trees. This is the hard part.
5862
return Object.assign(comment, {

src/parsers/javascript.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function _addComment(
103103

104104
if (t.isClassMethod(path) && path.node.kind === 'constructor') {
105105
// #689
106-
if (!comment.hideconstructor) {
106+
if (comment.tags.some(tag => tag.title !== 'param' && tag.title !== 'hideconstructor')) {
107107
debuglog(
108108
'A constructor was documented explicitly: document along with the class instead'
109109
);

0 commit comments

Comments
 (0)