kungfooman / RuntimeTypeInspector.js

Checking JSDoc types at runtime for high-quality types - Trust is good, control is better.
MIT License
8 stars 0 forks source link

JSDoc parsing: Improve `@param` end detection for special cases #183

Closed kungfooman closed 2 weeks ago

kungfooman commented 2 weeks ago
/**
 * @param {number[]} [nodes] - Defaults to [].
 */
function test(nodes = []) {
  return nodes;
}
const ret = test([1, 2, 3]);
console.log('ret', ret);

Currently it believes the last ] from the comment belongs to the type, resulting in this error:

Asserter.js:178 generateTypeChecks> test> todo implement AssignmentPattern for parameter nodes]
warn    @   Asserter.js:178
generateTypeChecks  @   Asserter.js:549
BlockStatement  @   Stringifier.js:555