Permalink
Browse files

Improve Button and Tag types

  • Loading branch information...
yesmeck committed May 18, 2018
1 parent 7c4f6e8 commit 1ed9fed2cf1c99b947359fafb101b2e58213cb48
Showing with 4 additions and 7 deletions.
  1. +3 −6 components/button/button.tsx
  2. +1 −1 components/tag/index.tsx
@@ -4,7 +4,6 @@ import PropTypes from 'prop-types';
import classNames from 'classnames';
import omit from 'omit.js';
import Icon from '../icon';
import { Omit } from '../_util/type';
import Group from './button-group';
const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/;
@@ -39,7 +38,7 @@ export type ButtonType = 'default' | 'primary' | 'ghost' | 'dashed' | 'danger';
export type ButtonShape = 'circle' | 'circle-outline';
export type ButtonSize = 'small' | 'default' | 'large';
export interface BaseButtonProps<T> extends Omit<React.HTMLProps<T>, 'ref' | 'size'> {
export interface BaseButtonProps {
type?: ButtonType;
htmlType?: string;
icon?: string;
@@ -51,11 +50,9 @@ export interface BaseButtonProps<T> extends Omit<React.HTMLProps<T>, 'ref' | 'si
ghost?: boolean;
}
export interface AnchorButtonProps extends BaseButtonProps<HTMLAnchorElement> {
href: string;
}
export type AnchorButtonProps = BaseButtonProps & React.AnchorHTMLAttributes<HTMLAnchorElement>;

This comment has been minimized.

@yesmeck

yesmeck Jun 12, 2018

Member

By using type intersection, we don't need to omit ref and size?

This comment has been minimized.

@zheeeng

zheeeng Jun 12, 2018

Contributor

@yesmeck Sorry, I made mistakes and deleted these comments. A little suggestion, we can use object spreading to eliminate omit function usage. As PR #10877 did.

export interface NativeButtonProps extends BaseButtonProps<HTMLButtonElement> {}
export type NativeButtonProps = BaseButtonProps & React.ButtonHTMLAttributes<HTMLButtonElement>;
export type ButtonProps = AnchorButtonProps | NativeButtonProps;
@@ -8,7 +8,7 @@ import CheckableTag from './CheckableTag';
export { CheckableTagProps } from './CheckableTag';
export interface TagProps {
export interface TagProps extends React.HTMLAttributes<HTMLDivElement> {
prefixCls?: string;
className?: string;
color?: string;

0 comments on commit 1ed9fed

Please sign in to comment.