Is there some way to make a JSX expression like <div></div> have a type other than JSX.Element without casting it?
I'm wondering, because with Solid (one of the fastest view libs), which uses JSX for convenient syntax for creating DOM with reactive expressions, the type of div in
consdiv=<div></div>// it is a div element, we can use DOM APIs:div.setAttribute('foo','bar')
in plain JavaScript is actually HTMLDivElement; div is a reference to an actual <div> element after the assignment.
I'm wondering if there's a way to make that typing possible, without having to write something like
constdiv=(<div></div>)asunknownasHTMLDivElement
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Is there some way to make a JSX expression like
<div></div>
have a type other thanJSX.Element
without casting it?I'm wondering, because with Solid (one of the fastest view libs), which uses JSX for convenient syntax for creating DOM with reactive expressions, the type of
div
inin plain JavaScript is actually
HTMLDivElement
;div
is a reference to an actual<div>
element after the assignment.I'm wondering if there's a way to make that typing possible, without having to write something like