-
-
Notifications
You must be signed in to change notification settings - Fork 321
[button] Remove discriminated props union #3643
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
base: master
Are you sure you want to change the base?
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
1229d0a to
81c0869
Compare
battaglr
left a comment
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.
Great! I cannot think of any other way of typing this so TS can properly infer types for native and non-native buttons. Maybe there's some TS dark magic that we don't know about? Even then, I think this is a good enough. 🙌
| "type": "boolean", | ||
| "detailedType": "boolean | undefined" | ||
| }, | ||
| "disabled": { |
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.
Why is this removed?
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.
We could add dev-time warnings if native button props are used alongside nativeButton={false}
Trying to use
Omit,& {...},extendsetc. breaks theButton.Propstype. All other button components (e.g.Popover.Trigger) do not yet handle this either. It can be solved with overloads, but this also requires wrappers to handle overloads as well to retain the typesafety. The types for all button components can be changed in a separate PR.Fixes #3641