Created
December 10, 2023 06:43
-
-
Save guiseek/2516cf67cddd27dd9a183c8c861e09a2 to your computer and use it in GitHub Desktop.
HTML, SVG and MathML ElementTagNameMaps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type HTMLs = HTMLElementTagNameMap | |
export type SVGs = SVGElementTagNameMap | |
export type MathMLs = MathMLElementTagNameMap | |
export type Tags = keyof (HTMLs | SVGs | MathMLs) | |
export type HTMLByTag<K extends keyof HTMLs> = HTMLs[K] | |
export type SVGByTag<K extends keyof SVGs> = SVGs[K] | |
export type MathMLByTag<K extends keyof MathMLs> = MathMLs[K] | |
export type ElementByTag<K extends Tags> = K extends keyof HTMLs | |
? HTMLByTag<K> | |
: K extends keyof SVGs | |
? SVGByTag<K> | |
: K extends keyof MathMLs | |
? MathMLByTag<K> | |
: Element | |
export type ElementFn<K extends Tags> = (props: object) => ElementByTag<K> | |
export type ElementType = 'html' | 'svg' | 'mathMl' | 'custom' | |
export type TagsByType<K extends ElementType> = K extends 'html' | |
? keyof HTMLs | |
: K extends 'svg' | |
? keyof SVGs | |
: K extends keyof MathMLs | |
? keyof MathMLs | |
: keyof Tags | |
export type Constructor<T> = new (...args: any[]) => T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment