Skip to content
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

fix: better typings with Polymorphic Box #21

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

astahmer
Copy link
Contributor

currently (no matter what was passed to the as prop), all html element props are passed/suggested:

Screenshot 2022-10-31 at 14 14 22

this PR propose more accurates typings

using custom component, only the props exposed are now suggested:
Screenshot 2022-10-31 at 14 13 06

using html element:
Screenshot 2022-10-31 at 14 12 53

@astahmer astahmer mentioned this pull request Nov 10, 2022
@astahmer
Copy link
Contributor Author

astahmer commented Dec 22, 2022

for anyone stumbling on this PR, I did it in a way that allows full customization in user-code here, also included a fix for this issue #20 here

@TheMightyPenguin
Copy link
Owner

Hey @astahmer thanks for this! And sorry for the delay. I think having this does make the experience better, but I actually issues with similar approaches in the past 😅 I had something similar when I started this library, but reverted it as it can cause typescript performance issues in large codebases.

I will merge it for now as I do prefer this developer experience, but if it has performance issues we could change the polymorphic approach to something similar to what Radix does with the asChild prop https://www.radix-ui.com/docs/primitives/components/dialog#trigger

@TheMightyPenguin TheMightyPenguin merged commit 4d88fc9 into TheMightyPenguin:main Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants