From da8e865f23999bf62774c6905990dd13ccb3ebcf Mon Sep 17 00:00:00 2001 From: Andre Luiz Rabello Date: Tue, 12 Oct 2021 11:08:26 +0100 Subject: [PATCH] fix(react): button type overloads (#1053) --- packages/react/src/components/button/button.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/react/src/components/button/button.tsx b/packages/react/src/components/button/button.tsx index 5d1777d4f..d3a772e0d 100755 --- a/packages/react/src/components/button/button.tsx +++ b/packages/react/src/components/button/button.tsx @@ -29,11 +29,13 @@ export const Button: ButtonComponent = withRef(function Button( }); export type ButtonProps = BaseProps & - (T extends 'a' ? AnchorElementProps : ButtonElementProps); + (T extends 'a' + ? { href: string } & AnchorElementProps + : { href?: never } & ButtonElementProps); type ButtonComponent = { - (props: BaseProps & AnchorElementProps, ref: AnchorRef): JSX.Element; - (props: BaseProps & ButtonElementProps, ref: ButtonRef): JSX.Element; + (props: ButtonProps<'a'>, ref: AnchorRef): JSX.Element; + (props: ButtonProps<'button'>, ref: ButtonRef): JSX.Element; }; type AnchorElementProps = JSX.IntrinsicElements['a'] & { ref?: AnchorRef };