Skip to content

Commit

Permalink
ensure type data is not clobbered with data from getDefaultJSDocType()
Browse files Browse the repository at this point in the history
  • Loading branch information
ekhaled committed Aug 28, 2021
1 parent 49bff24 commit 45777c2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/v3/v3-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const {
parseTypeKeyword
} = require('../jsdoc');

const { inferTypeFromVariableDeclaration } = require('../utils');

class InvalidNodeTypeError extends TypeError {
constructor(expected, actual = '', ...args) {
super(expected, actual, ...args);
Expand Down Expand Up @@ -193,7 +195,24 @@ function parseAndMergeKeywords(keywords = [], event, allowToParseReturn = true)
* present from parsing the AST node.
*/
if (pIndex >= 0) {
event.params[pIndex] = parsedParam;
if(
parsedParam.type &&
event.params[pIndex].type &&
parsedParam.type.text == '*'
){
/**
* Only `getDefaultJSDocType()` has type.text = "*"
* so, if parsedParams contain that, we can be sure that
* type information was not found in the keyword description
*
* When that happens, we check if type data is already present
* from parsing the assignment pattern in the FunctionDeclaration
*/
parsedParam.type = event.params[pIndex].type;
parsedParam.optional = event.params[pIndex].optional;
}

event.params[pIndex] = Object.assign(event.params[pIndex], parsedParam);
} else {
/*
* This means @param does not match an actual param
Expand Down

0 comments on commit 45777c2

Please sign in to comment.