Solid: 'xmlns' does not exist on svg

Created on 19 Dec 2020  路  7Comments  路  Source: ryansolid/solid

I'm pretty new to TS so this is almost certainly a user error. Nevertheless, I can't figure out what type definition to use for my svg template (which takes polygon children and wraps them in svg scaffolding, it also accepts props that set the size and color or the svg). I have stopped getting tons of errors with JSX.Element but I'm not sure if that's right. What I am getting now, though, is complaints on xmlns, fill, and stroke like:

Property 'xmlns' does not exist on type 'SvgSVGAttributes'.

My SvgTemplate component looks like this:

import { JSX } from "solid-js"

type Props = {
    color?: string;
    size?: number;
}
const SvgTemplate: (...children: any) => (props: Props) => JSX.Element = (
    ...children: any
) => (props: Props) =>
        <svg
            xmlns="http://www.w3.org/2000/svg"
            width={props.size || 24}
            height={props.size || 24}
            viewBox="0 0 24 24"
            fill="none"
            stroke={props.color || "currentColor"}
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
            class="feather feather-activity"
        >
            {children}
        </svg>

export default SvgTemplate

If my issue is not solidjs-related, I apologise. I blame my unfamiliarity with the ts + solid stack.

bug

All 7 comments

Yeah looks likes an omission. I can get that fixed in the next release. Getting the TSX types working has been largely a community effort. Don't hesitate to report any other missing ones. Thank you.

I'm curious what changed in 96566af that fixes this issue. If you have a chance to point me in the right direction, I'd be grateful.

It's because Solid is built using the DOM Expressions toolkit. I updated the version of the DOM Expressions library, the JSX types are there: https://github.com/ryansolid/dom-expressions/blob/master/packages/dom-expressions/src/jsx.d.ts

I've merged this but just working on a couple other things hopefully get the release out in the next day or so.

Great, thanks for the explanation!
Really appreciate your work on this project!

Ok it's been released in v0.23.5.

I'm sorry, I actually checked the commit at https://github.com/ryansolid/dom-expressions/commit/f1cfb849eac03dd8cc52d42621ede07707f4e86f and thought perhaps I didn't understand something but I think these attributes are still missing (from SvgSVGAttributes):

  • fill
  • stroke

Oh.. yeah for some reason I only read xmlns I didn't add the others. Easy to remedy, sorry about that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samadadi picture samadadi  路  7Comments

cliqqz picture cliqqz  路  3Comments

ryansolid picture ryansolid  路  8Comments

aguilera51284 picture aguilera51284  路  8Comments

russelgal picture russelgal  路  3Comments