-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add types for props from .attrs and "as" #4291
base: main
Are you sure you want to change the base?
Conversation
I use your branch locally to test the .attrs issue in my project, but the #4076 issue still happening to me:
My Icon component:
My Icon is a SVG. It happens with my other component which is styled.text too.
What I find strange is that when instantiating the component with styled components, the .attrs is not correctly reading the component's typing, even if I determine that it is mandatory, autocomplete only shows it as optional, and does not report an error in the time to instantiate. |
@carloslibardo could you format your comment properly using github code markdown and give the definition for the Icon component and I can take a look? |
@bjornsnoen i updated the comment with more infos |
I ended up taking the other PR, can you check to see if your issue is resolved with current |
Even if #4288 solves the |
Optional< | ||
PrivateResolvedTarget extends KnownTarget | ||
? Substitute< | ||
Substitute<OuterProps, React.ComponentPropsWithRef<PrivateResolvedTarget>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using ComponentPropsWithRef after importing it with import type { ComponentPropsWithRef } from 'react'; would improve readability, I think.
Fixes:
Noticed that someone else opened PR #4288 yesterday, I will assume that their fix for
attrs
is more correct than mine but I'll leave this until that PR is merged or other wise addressed.