-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request]: Add Web Components Typing to the TypeScript guide #823
Comments
Here's what I do for Lume elements for example: declare module 'solid-js' {
namespace JSX {
interface IntrinsicElements {
'lume-point-light': ElementAttributes<PointLight, PointLightAttributes>
}
}
}
declare global {
interface HTMLElementTagNameMap {
'lume-point-light': PointLight
}
} That If you want to also support other frameworks like React, Preact, Vue, Svelte, etc (they all use JSX type defs) then you can make separate files for each framework (because they may have different JSX type layouts) that someone can import to gain the types. For example here's the React JSX definition for that same import type {ReactElementAttributes} from '@lume/element/src/react'
// React users can import this to have appropriate types for the element in their JSX markup.
declare global {
namespace JSX {
interface IntrinsicElements {
'lume-point-light': ReactElementAttributes<PointLight, PointLightAttributes>
}
}
}
export type PointLightAttributes = LightWithShadowAttributes | 'distance' | 'decay' where |
Hey, folks. Right out of the bat, I feel WebComponents shouldn't live within a TypeScript section. For 2 reasons:
So, my initial hunch (and it really is a hunch, I haven't worked seriously with WebComponents in a long time), the bulk of the guide should fit in Solid's core, at the Learn section and either in "Advanced Concepts", "Guides", and/or "Configuration". Do y'all have thoughts? All that mentioned above considered, @DBozhinovski has volunteered |
👋 Hey all! Happy to pitch in :) My 2c, and something I've discussed with @atilafassina already - when we discuss "web components", we are fundamentally discussing two different things - authoring them (as most modern UI libs/frameworks are already capable of doing, Solid included via SolidElement) and using third-party web components inside a UI lib/framework. In the case of Solid, from my experience so far, the latter mostly comes down to:
We could possibly improve this by providing some examples of how to use web components inside Solid (popular libs with types, without types etc.) The former (authoring web components via Solid Element), could use some docs and guides IMO. The README in the Plus, making it more public that Solid can be used to author web components is kind of a big deal, given their rise in popularity. I promise I volunteered 😉 |
What is this request related to?
Request
📋 Suggested
https://docs.solidjs.com/configuration/typescript#typescript
📋 General description or bullet points
It's come to my attention that we don't talk about how to use webcomponents in the new docs anywhere. There was an old discussion here: solidjs/solid#616 that sheds some light but the answer is little bit lost.
It doesn't necessarily need to go in the TS section but it does feel like it makes sense because it uses similar overrides to custom events, props etc..
🖥️ Reproduction of code samples in StackBlitz
No response
The text was updated successfully, but these errors were encountered: