Skip to content

Commit

Permalink
Parse type applications correctly in Node.js 12. (#1643)
Browse files Browse the repository at this point in the history
Also enables CI for Node.js 12, which I had neglected to do.
  • Loading branch information
hegemonic committed May 5, 2019
1 parent e5919e4 commit bac40ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ language: node_js
node_js:
- "8"
- "10"
- "12"

install: npm install -g gulp; npm install
13 changes: 5 additions & 8 deletions lib/jsdoc/tag/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const jsdoc = {
cast: require('jsdoc/util/cast')
}
};
const util = require('util');

/**
* Information about a type expression extracted from tag text.
Expand Down Expand Up @@ -196,9 +195,9 @@ function getTypeStrings(parsedType, isOutermostType) {
case TYPES.TypeApplication:
// if this is the outermost type, we strip the modifiers; otherwise, we keep them
if (isOutermostType) {
applications = parsedType.applications.map(application => catharsis.stringify(application)).join(', ');
typeString = util.format( '%s.<%s>', getTypeStrings(parsedType.expression),
applications );
applications = parsedType.applications.map(application =>
catharsis.stringify(application)).join(', ');
typeString = `${getTypeStrings(parsedType.expression)[0]}.<${applications}>`;

types.push(typeString);
}
Expand All @@ -219,8 +218,7 @@ function getTypeStrings(parsedType, isOutermostType) {
break;
default:
// this shouldn't happen
throw new Error( util.format('unrecognized type %s in parsed type: %j', parsedType.type,
parsedType) );
throw new Error(`unrecognized type ${parsedType.type} in parsed type: ${parsedType}`);
}

return types;
Expand All @@ -247,8 +245,7 @@ function parseTypeExpression(tagInfo) {
}
catch (e) {
// always re-throw so the caller has a chance to report which file was bad
throw new Error( util.format('Invalid type expression "%s": %s', tagInfo.typeExpression,
e.message) );
throw new Error(`Invalid type expression "${tagInfo.typeExpression}": ${e.message}`);
}

tagInfo.type = tagInfo.type.concat( getTypeStrings(parsedType, true) );
Expand Down

0 comments on commit bac40ab

Please sign in to comment.