#SVG interface for typescript?

1 messages · Page 1 of 1 (latest)

hearty glen
#

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 repository

silk harness
hearty glen
#

Module '"solid-js"' has no exported member 'SVGElementTags'

#

and I can't figure out where the interface is

silk harness
#

There are SVGElements on solid-js/web - does that work?

hearty glen
#

hmmm

#

'SVGElements' refers to a value, but is being used as a type here. Did you mean 'typeof SVGElements'?

surreal pine
#

I think you can use JSX.UseSVGAttributes

silk harness
#

How about
import type {SVGElements} from "solid-js/web"

hearty glen
hearty glen
surreal pine
#

So you should be able to do JSX.UseSVGAttributes<SVGPathElement> to get the attributes for the path element

hearty glen
#

ooooh, that explains it- but then is there a single type that aggregates everything for the <svg /> tag itself?

surreal pine
#

SVGSVGElement

hearty glen
#

oh

surreal pine
#

or do you mean for all svg attributes for all svg elements?

hearty glen
#

that seems to work perfectly lol

surreal pine
#

ah I made a mistake

hearty glen
#

hmm?

surreal pine
#

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>

hearty glen
#

oooo

surreal pine
#

nope

#

still wrong oops

#

weird

#

Actually that is correct but I guess my lsp is just being weird

hearty glen
#

ahh

surreal pine
#

JSX.SVGElementTags['path'] this method seems more correct

#

Weird that I haven't run into this since I've used svg so much

hearty glen
#

ahh

#

also, is it just me or is the server having issues? lol

surreal pine
#

what type of issues?

#

Could be discord

hearty glen
#

like #general won't load at all

#

nor will the main UI for #1047251592610599032

surreal pine
#

oh not sure, seems to be working for me

hearty glen
#

weird

surreal pine
#

Decided to restart discord to check and it stopped working lol

hearty glen
#

yeah