runem / web-component-analyzer

CLI that analyzes web components and emits documentation
https://runem.github.io/web-component-analyzer
MIT License
507 stars 65 forks source link

Boolean attr with default value #147

Closed bennypowers closed 4 years ago

bennypowers commented 4 years ago

Input

/**
 * If true, when updates are found, the page will automatically
 * reload, so long as the user has not yet interacted with it.
 * @attr {boolean} [auto-reload=false]
 */
get autoReload() {
  return this.hasAttribute('auto-reload');
}

Expected

Property Attribute Type Default Description
autoReload auto-reload boolean false If true, when updates are found, the page will automatically
reload, so long as the user has not yet interacted with it.

Actual

Property Attribute Type Default Description
autoReload auto-reload boolean If true, when updates are found, the page will automatically
reload, so long as the user has not yet interacted with it.

If I apply @default false, I get

Property Attribute Type Default Description
autoReload auto-reload boolean "false" If true, when updates are found, the page will automatically
reload, so long as the user has not yet interacted with it.
bennypowers commented 4 years ago

@workaround {AwfulHack}: I can put this at the very end of my constructor

if (this.hasAttribute('auto-reload')) return;

this.autoReload = false;
runem commented 4 years ago

Hey, thanks for opening this issue :-)

I forgot to apply default values when parsing/applying jsdoc for members of a component. It has been fixed now, and will be included in the next release.