Created
June 27, 2019 17:25
-
-
Save danakt/7771808d40b9c1e2ef49fff66326f3e8 to your computer and use it in GitHub Desktop.
Returns type of HTML element by tag name
This file contains 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
/** | |
* Returns type of HTML element by tag name | |
* @example | |
* type ElementType = GetElementByTagname<'div'> // HTMLDivElement | |
*/ | |
type GetElementByTagName< | |
Tagname extends keyof React.ReactHTML | |
> = React.ReactHTML[Tagname] extends React.DetailedHTMLFactory<infer A, infer E> ? E : null; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment