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

Breaking change in MenuItemProps #25887

Closed
ling1726 opened this issue Dec 5, 2022 · 1 comment · Fixed by #26257 or #26261
Closed

Breaking change in MenuItemProps #25887

ling1726 opened this issue Dec 5, 2022 · 1 comment · Fixed by #26257 or #26261

Comments

@ling1726
Copy link
Member

ling1726 commented Dec 5, 2022

Change was introduced in #24738, After that PR it's no longer possible to reuse the prop type using Partial<MenuItemProps> because of the typed event handler.

In the below repro, simply remove the onClick handler to remove the TS error

https://codesandbox.io/s/still-https-kjlbz5?file=/example.tsx

@bsunderhus
Copy link
Contributor

bsunderhus commented Jan 9, 2023

The problem

Just to give my two cents on this topic:

This is not a direct problem on our side, technically the changes provided by #24738 are not breaking changes as they support the same surface API. The problem here is that since we adopted ARIAButton types from that PR and forward, we've introduced an union of type on the root of the component.

It is a known problem to properly break an union in TS. And using Partial (as is the case of the mentioned example) is basically breaking down an union. Here's an example of this problem in a smaller scale

Proposed solutions

  1. Let's simply not break unions! And in this case in particular there's absolutely no reason to break MenuItemProps with Partial, as all it's properties are already optional.
  2. Let's not use an union on root (stop using ARIAButton type)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.