Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve Button and Tag types
  • Loading branch information
yesmeck committed May 18, 2018
1 parent 7c4f6e8 commit 1ed9fed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions components/button/button.tsx
Expand Up @@ -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}$/;
Expand Down Expand Up @@ -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;
Expand All @@ -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.

Copy link
@yesmeck

yesmeck Jun 12, 2018

Author Member

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

This comment has been minimized.

Copy link
@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;

Expand Down
2 changes: 1 addition & 1 deletion components/tag/index.tsx
Expand Up @@ -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;
Expand Down

0 comments on commit 1ed9fed

Please sign in to comment.