SVG interface for typescript?
Hi,
Does Solid have an
SVGAttributes
(or similar) interface for use with typescript SVG components? I can't seem to find any in the github repository27 Replies
There were some improvements to svg JSX types in Solid 1.8 - not sure if related, just fyi. https://github.com/solidjs/solid/issues/1905
GitHub
JSX types for SVG elements (
SVGElementTags
) wrongly use runtime D...Describe the bug As part of an SVG element I was building with solid, I wanted to use an <feDropShadow> element like this: <feDropShadow in='SourceGraphic' dx='0.2' dy='...
Module '"solid-js"' has no exported member 'SVGElementTags'
and I can't figure out where the interface isThere are SVGElements on solid-js/web - does that work?
hmmm
'SVGElements' refers to a value, but is being used as a type here. Did you mean 'typeof SVGElements'?
I think you can use
JSX.UseSVGAttributes
How about
import type {SVGElements} from "solid-js/web"
already tried that, and it doesn't make any difference
that's a generic type, but I still can't find the typescript interface for the tag itself, unless I'm supposed to use {} in lieu of a concrete type, or something?
for specific tags you should be able to just use html types like
SVGPathElement
So you should be able to do JSX.UseSVGAttributes<SVGPathElement>
to get the attributes for the path elementooooh, that explains it- but then is there a single type that aggregates everything for the
<svg />
tag itself?SVGSVGElement
oh
or do you mean for all svg attributes for all svg elements?
that seems to work perfectly lol
ah I made a mistake
hmm?
actually you can use
SvgSVGAttributes
type from jsx, instead of UseSVGAttributes
it should give you the proper types for any svg element you pass it
JSX.SvgSVGAttributes<SVGSVGElement>
oooo
nope
still wrong oops
weird
Actually that is correct but I guess my lsp is just being weird
ahh
JSX.SVGElementTags['path']
this method seems more correct
Weird that I haven't run into this since I've used svg so muchahh
also, is it just me or is the server having issues? lol
what type of issues?
Could be discord
like #general won't load at all
nor will the main UI for #support
oh not sure, seems to be working for me
weird
Decided to restart discord to check and it stopped working lol
yeah
lol