Repository navigation
|
As far as I can see solid.js allows me to use web components directly in the jsx template. In runtime in works fine, but typescript says there is an error According to logs from ts language server it use If I add my custom component in solidjs definitions - ts finally happy The thing I can't figure out is why I can't extend the solid.js JSX namespace, and how should custom components in project with solid js |
Replies: 3 comments 1 reply
|
We don't pollute the global TypeScript namespace with our JSX definition. While there isn't a custom elements example it should be roughly the same: https://www.solidjs.com/guides/typescript#special-jsx-attributes-and-directives. Notice module "solid-js" and you may need to import JSX from "solid-js" as well. |
|
@ryansolid thank you! Next code in declare global {
declare module "solid-js" {
namespace JSX {
interface IntrinsicElements {
'map-gl': MapGlProps;
}
}
}
} |
|
In case anyone else gets stuck, this took me way too long to figure out so I'll share here. Kudos @Akiyamka for figuring that out and putting me on the right track after a frustrating couple of days searching and failing. I was trying to get it to recognize the web components in the mdui library in SolidJS. Here's what ultimately worked for me: In import "mdui/jsx.en";
declare module "solid-js" {
namespace JSX {
interface IntrinsicElements extends globalThis.JSX.IntrinsicElements {}
}
} |



@ryansolid thank you! Next code in
index.d.tscover my case! Import of JSX from solid-js not required