-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Styling components with required props triggering an TypeScript error #472
Comments
Thanks @theBork for opening this issue. Might be due to this line https://github.com/cristianbote/goober/blob/master/goober.d.ts#L32 wondering how can I add the |
@cristianbote yes, I think that JSX.Element, that used in this line of code describes type of Element like that:
or
When we provide our component as argument to styled method, they are not Element yet, so I think changing to JSX.FC will help. I can make PR next days, if you want :) |
That would be super helpful @theBork! Much appreciated. |
One way i was able to solve this was adding types to the styled(tag) i already created a pull request for it Also i was able to get it done with React.ElementType as well but i couldn't add that to the repo as Goober is used/can be used in a none react app |
When I try to wrap custom React components with goober's "styled" method, TypeScript shows error im cases when component have required props.
When I change
myProp
to optional, there is no errors.TypeScript: 4.7.4
Goober: 2.1.10
Sandbox with problem's example: https://codesandbox.io/s/goober-typescript-styled-custom-component-y25bq0?file=/src/Component.tsx
The text was updated successfully, but these errors were encountered: