runem / web-component-analyzer

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

[Support] Typing Data Attributes #162

Open bennypowers opened 4 years ago

bennypowers commented 4 years ago

consider

const enum ColumnType {
  data = 'data',
  action = 'action',
  link = 'link',
}

interface ColumnBase {
  type: ColumnType;
}

/**
 * @element table-column
 * @attr {ColumnType} data-type
 */
export class TableColumn extends HTMLElement {
   dataset: DOMStringMap & Column;
}

I'd expect editor tools to throw on <table-column action="💩">, but it seems to validate.

What is the proper way to type data attributes?