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.
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):
fillstrokeOh.. yeah for some reason I only read xmlns I didn't add the others. Easy to remedy, sorry about that.