From 3b4de906f59011ecc7cb941c92309156a2f39e26 Mon Sep 17 00:00:00 2001 From: R Midhun Suresh Date: Sun, 22 Sep 2024 22:16:54 +0530 Subject: [PATCH] Use XOR instead of union Two problems when using union: 1. You can provided both a label and description and typescript won't complain about it. 2. You cant do TooltipProps["label"] or TooltipProps["description"]. --- src/components/Tooltip/Tooltip.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Tooltip/Tooltip.tsx b/src/components/Tooltip/Tooltip.tsx index 28bf65c6..a8e59c32 100644 --- a/src/components/Tooltip/Tooltip.tsx +++ b/src/components/Tooltip/Tooltip.tsx @@ -40,11 +40,12 @@ import { TooltipLabel, useTooltip, } from "./useTooltip"; +import { XOR } from "ts-xor"; // Unfortunately Omit doesn't distribute nicely over sum types, so we have to // piece together the useTooltip options type by hand type TooltipProps = Omit & - (TooltipLabel | TooltipDescription) & { + XOR & { /** * Whether the trigger element is interactive. * When trigger is interactive: