I have been having a lot of fun lately with custom JSX-elements (for example with this little side-project) : JSX are functions and functions can return more then dom-elements or any of the allowed JSXElement-types. Solidjs itself allows this approach, but it is impossible right now to properly type these components as types can not be augmented through declaration.
My proposal is to follow a pattern described hereinterface XRegistry { A:A B:B C:C }type X= XRegistry[keyof XRegistry];
//... And in the other file
declare module "someModule" { interface XRegistry { D:D } }
This way JSXElements could be augmented through a declaration-file as follows
declare module 'solid-js/jsx-runtime' { namespace JSX { interface CustomElement { test: string } interface ElementRegistry { CustomElement: CustomElement } } }
It creates identical code if not augmented, and works perfectly as is right now. If you want an example of it in action: (this repo) contains a patch with it working.
(I thought first to make the pull request with Solid, but the tests and builds kept on overwriting my changes, so I realized it was importing the types from here)
I have been having a lot of fun lately with custom JSX-elements (for example with this little side-project) : JSX are functions and functions can return more then dom-elements or any of the allowed JSXElement-types. Solidjs itself allows this approach, but it is impossible right now to properly type these components as types can not be augmented through declaration.
My proposal is to follow a pattern described here
interface XRegistry { A:A B:B C:C }
type X= XRegistry[keyof XRegistry];
//... And in the other filedeclare module "someModule" { interface XRegistry { D:D } }
This way JSXElements could be augmented through a declaration-file as follows
declare module 'solid-js/jsx-runtime' { namespace JSX { interface CustomElement { test: string } interface ElementRegistry { CustomElement: CustomElement } } }
It creates identical code if not augmented, and works perfectly as is right now. If you want an example of it in action: (this repo) contains a patch with it working.
(I thought first to make the pull request with Solid, but the tests and builds kept on overwriting my changes, so I realized it was importing the types from here)