Skip to content

Instantly share code, notes, and snippets.

Created July 15, 2019 08:57
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Map types
type AllElements = {
'a': HTMLAnchorElement;
'div': HTMLDivElement;
'span': HTMLSpanElement;
'ul': HTMLUListElement;
'title': HTMLTitleElement;
'textarea': HTMLTextAreaElement;
'template': HTMLTemplateElement;
'tfoot': HTMLTableSectionElement;
'thead': HTMLTableSectionElement;
'tbody': HTMLTableSectionElement;
'tr': HTMLTableRowElement;
'table': HTMLTableElement;
'col': HTMLTableColElement;
'colgroup': HTMLTableColElement;
'th': HTMLTableHeaderCellElement;
'td': HTMLTableDataCellElement;
'caption': HTMLTableCaptionElement;
'style': HTMLStyleElement;
'select': HTMLSelectElement;
'script': HTMLScriptElement;
'blockquote': HTMLQuoteElement;
'q': HTMLQuoteElement;
'progress': HTMLProgressElement;
'pre': HTMLPreElement;
'param': HTMLParamElement;
'p': HTMLParagraphElement;
'output': HTMLOutputElement;
'option': HTMLOptionElement;
'optgroup': HTMLOptGroupElement;
'object': HTMLObjectElement;
'ol': HTMLOListElement;
'ins': HTMLModElement;
'del': HTMLModElement;
'meter': HTMLMeterElement;
'meta': HTMLMetaElement;
'marquee': HTMLMarqueeElement;
'map': HTMLMapElement;
'video': HTMLVideoElement;
'audio': HTMLAudioElement;
'link': HTMLLinkElement;
'legend': HTMLLegendElement;
'label': HTMLLabelElement;
'li': HTMLLIElement;
'input': HTMLInputElement;
'img': HTMLImageElement;
'iframe': HTMLIFrameElement;
'html': HTMLHtmlElement;
'h1': HTMLHeadingElement;
'h2': HTMLHeadingElement;
'h3': HTMLHeadingElement;
'h4': HTMLHeadingElement;
'h5': HTMLHeadingElement;
'h6': HTMLHeadingElement;
'head': HTMLHeadElement;
'hr': HTMLHRElement;
'frameset': HTMLFrameSetElement;
'frame': HTMLFrameElement;
'form': HTMLFormElement;
'font': HTMLFontElement;
'fieldset': HTMLFieldSetElement;
'embed': HTMLEmbedElement;
'datalist': HTMLDataListElement;
'dl': HTMLDListElement;
'canvas': HTMLCanvasElement;
'button': HTMLButtonElement;
'body': HTMLBodyElement;
'base': HTMLBaseElement;
'br': HTMLBRElement;
'area': HTMLAreaElement
type CreatedHTMLElement<T extends keyof AllElements> = AllElements[T];
type CreatedElement<T extends string> =
T extends keyof AllElements ? CreatedHTMLElement<T> : HTMLElement;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment