type-fest
type-fest copied to clipboard
MergeExclusive with more than two types
I have several times had the use of a MergeExclusive that would support more than two types.
And yes, I can nest multiple uses but I currently had a case where I needed to force the selection of one of five cases. This resulted in a structure like below which is not very readable.
type Example = MergeExclusive<
MergeExclusive<
MergeExclusive<
DialogConfirmButtonProps,
DialogConfirmButtonProps & DialogCancelButtonProps
>,
DialogConfirmButtonProps &
DialogCancelButtonProps &
DialogCustomButtonsProps
>,
MergeExclusive<
DialogConfirmButtonProps & DialogCustomButtonsProps,
DialogCloseButtonProps
>
>
A better and more readable version would be:
type Example = MergeExclusive<
DialogConfirmButtonProps,
DialogConfirmButtonProps & DialogCancelButtonProps,
DialogConfirmButtonProps & DialogCancelButtonProps & DialogCustomButtonsProps,
DialogConfirmButtonProps & DialogCustomButtonsProps,
DialogCloseButtonProps
>
Is this something that is doable and desired? A assume that MergeExclusive could be extended to support more than two types without a breaking change?
Personally I do not have the competence to do it, otherwise this request would be a PR.
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- The funding will be given to active contributors.
- Thank you in advance for helping prioritize & fund our backlog.