From 35ae41f618012852e4dc20f843755344268635c1 Mon Sep 17 00:00:00 2001 From: Randy Date: Mon, 31 Jul 2017 00:42:25 +0800 Subject: [PATCH] remove `any` type in Tag (#7015) --- components/tag/CheckableTag.tsx | 2 +- components/tag/index.tsx | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/components/tag/CheckableTag.tsx b/components/tag/CheckableTag.tsx index 6a9b607a9c..fb9ae34877 100644 --- a/components/tag/CheckableTag.tsx +++ b/components/tag/CheckableTag.tsx @@ -8,7 +8,7 @@ export interface CheckableTagProps { onChange?: (checked: Boolean) => void; } -export default class CheckableTag extends React.Component { +export default class CheckableTag extends React.Component { handleClick = () => { const { checked, onChange } = this.props; if (onChange) { diff --git a/components/tag/index.tsx b/components/tag/index.tsx index 6efdd1ffe2..42ce55a943 100644 --- a/components/tag/index.tsx +++ b/components/tag/index.tsx @@ -19,7 +19,12 @@ export interface TagProps { style?: React.CSSProperties; } -export default class Tag extends React.Component { +export interface TagState { + closing: boolean; + closed: boolean; +} + +export default class Tag extends React.Component { static CheckableTag = CheckableTag; static defaultProps = { prefixCls: 'ant-tag', @@ -35,7 +40,7 @@ export default class Tag extends React.Component { }; } - close = (e) => { + close = (e: React.MouseEvent) => { const onClose = this.props.onClose; if (onClose) { onClose(e); @@ -52,7 +57,7 @@ export default class Tag extends React.Component { }); } - animationEnd = (_, existed) => { + animationEnd = (_: string, existed: boolean) => { if (!existed && !this.state.closed) { this.setState({ closed: true, @@ -66,7 +71,8 @@ export default class Tag extends React.Component { } } - isPresetColor(color) { + isPresetColor(color?: string): boolean { + if (!color) { return false; } return /^(pink|red|yellow|orange|cyan|green|blue|purple)(-inverse)?$/.test(color); }