-
Notifications
You must be signed in to change notification settings - Fork 209
Type definition for typescript doesn't include built-in components. #294
Comments
Hey @Kais-DkM, thanks for reporting that. That would be a great addition to the types. Given the size of those interfaces, it would be good if they were in an adjacent file. // built-in-glamorous-components.d.ts
export interface HTMLComponent {
Div: React.StatelessComponent<CSSProperties & ExtraGlamorousProps>
// ...
}
export interface SVGComponent {
Svg: React.StatelessComponent<CSSProperties & ExtraGlamorousProps>
// ...
} There's also an issue with the typings for these in that they are typed to take the relevant HTMLProps. export interface HTMLComponent {
A: React.StatelessComponent<CSSProperties & ExtraGlamorousProps & React.HTMLProps<HTMLAnchorElement>>
Div: React.StatelessComponent<CSSProperties & ExtraGlamorousProps & React.HTMLProps<HTMLDivElement>>
Svg: React.StatelessComponent<CSSProperties & ExtraGlamorousProps & React.SVGAttributes<SVGElement>>
}
export interface SVGComponent {
Svg: React.StatelessComponent<CSSProperties & ExtraGlamorousProps & React.SVGAttributes<SVGElement>>
} If you're able to open a PR along the lines of either of the above, or another strategy/structure you think would work well, that would be greatly appreciated. |
@luke-john Why wasn't this implemented until now? |
@luke-john |
@Kais-DkM it was because no one had tried to work on it. Looks like there's already a PR open, but thank you for your offer to work on this 👍. If you're still interested in helping out with the typings I'll be opening some issues later this week with good first prs to help improve the developer experience. #295 |
@luke-john |
glamorous
version: 4.2.0glamor
version: 2.20.40react
version: 15.6.1Relevant code.
Problem description:
Currently for typescript, there's no type definition for built-in components other than
Div
andSvg
.Of course I can use them as
glamorous.span({...})
, but it would be better if I can use built-in components too.Suggested solution:
I think adding interface
HTMLComponents
having all those built-in components, and makingGlamorousInterface
extend it would be enough.Like this:
The text was updated successfully, but these errors were encountered: