JSX types for SVG elements (SVGElementTags
) wrongly use runtime DOM element types instead of attributes
#1905
Labels
Milestone
Describe the bug
As part of an SVG element I was building with
solid
, I wanted to use an<feDropShadow>
element like this:only to find out that TypeScript was complaining about
dx
anddy
having wrong types, expecting an object of the shapeSVGAnimatedNumber
.And that's because
feDropShadow
is defined asPartial<SVGFEDropShadowElement>
in interfaceSVGElementTags
, in filesolid-js/types/jsx.d.ts
The issue here is that
SVGFEDropShadowElement
, defined intypescript/lib/lib.dom.d.ts
, represents the runtime instance of the created element, not the input attributes type, which should define the inputsdx
/dy
I mentioned as numbers/strings (for an example, here's how it's defined in React:@types/react/index.d.ts
).Your Example Website or App
https://stackblitz.com/edit/solidjs-templates-xd2mqb?file=src%2FApp.tsx
Steps to Reproduce the Bug or Issue
Just write a
solid
component with JSX in TypeScript and try definingdx
ordy
with numbers or strings on a<feDropShadow>
element: the tooling (IDE, compiler, etc.) will report an error.Expected behavior
The type definition should accept numbers/strings and not an
SVGAnimatedNumber
object. But more importantly, all JSX SVG element types should be defined according to their input attributes, not to their corresponding runtime instance objects.Screenshots or Videos
Platform
solid
version:1.7.12
Additional context
No response
The text was updated successfully, but these errors were encountered: