Search code examples
typescriptsolid-js

Solid JS equivalent of React.HTMLProps<...>


I have a React component with prop types like:

type Props = React.HTMLProps<HTMLAnchorElement> & {
    to?: string;
};

How do you write the equivalent prop types in SolidJS? I tried this:

type Props = Component<HTMLAnchorElement> & {
    to?: string;
};

And it compiles, but it does not have the same built in props as the former such as children.


Solution

  • Solid JS has JSX.IntrinsicElements which provides properties types indexed by tag name:

    import { JSX } from 'solid-js';
    
    type Props = JSX.IntrinsicElements['a'] & {
        to?: string;
    };