From 9190245b521c5c68eaff2358361478b4d5b342ef Mon Sep 17 00:00:00 2001 From: zombieJ Date: Mon, 8 Apr 2019 18:04:46 +0800 Subject: [PATCH] update ts def (#15938) --- components/button/button.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/button/button.tsx b/components/button/button.tsx index 1827d994a6..88a8795b2e 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -62,20 +62,23 @@ export interface BaseButtonProps { children?: React.ReactNode; } +// Typescript will make optional not optional if use Pick with union. +// Should change to `AnchorButtonProps | NativeButtonProps` and `any` to `HTMLAnchorElement | HTMLButtonElement` if it fixed. +// ref: https://github.com/ant-design/ant-design/issues/15930 export type AnchorButtonProps = { href: string; target?: string; - onClick?: React.MouseEventHandler; + onClick?: React.MouseEventHandler; } & BaseButtonProps & - Omit, 'type'>; + Omit, 'type'>; export type NativeButtonProps = { htmlType?: ButtonHTMLType; - onClick?: React.MouseEventHandler; + onClick?: React.MouseEventHandler; } & BaseButtonProps & - Omit, 'type'>; + Omit, 'type'>; -export type ButtonProps = AnchorButtonProps | NativeButtonProps; +export type ButtonProps = Partial; interface ButtonState { loading?: boolean | { delay?: number };