Fix implicit any for Select Slider Spin Switch

This commit is contained in:
Wei Zhu 2017-11-21 14:53:25 +08:00
parent 5cb5a2ae9d
commit b647078baa
5 changed files with 38 additions and 15 deletions

View File

@ -85,7 +85,7 @@ const SelectPropTypes = {
// => It is needless to export the declaration of below two inner components.
// export { Option, OptGroup };
export default class Select extends React.Component<SelectProps, any> {
export default class Select extends React.Component<SelectProps, {}> {
static Option = Option as React.ClassicComponentClass<OptionProps>;
static OptGroup = OptGroup as React.ClassicComponentClass<OptGroupProps>;
@ -108,11 +108,11 @@ export default class Select extends React.Component<SelectProps, any> {
this.rcSelect.blur();
}
saveSelect = (node) => {
saveSelect = (node: any) => {
this.rcSelect = node;
}
renderSelect = (locale) => {
renderSelect = (locale: SelectLocale) => {
const {
prefixCls,
className = '',

View File

@ -13,6 +13,13 @@ export interface SliderMarks {
export type SliderValue = number | [number, number];
export type HandleGeneratorFn = (info: {
value: number,
dragging: boolean,
index: number,
rest: any[],
}) => React.ReactElement<any>;
export interface SliderProps {
prefixCls?: string;
tooltipPrefixCls?: string;
@ -34,23 +41,27 @@ export interface SliderProps {
id?: string;
}
export default class Slider extends React.Component<SliderProps, any> {
export interface SliderState {
visibles: { [index: number]: boolean };
}
export default class Slider extends React.Component<SliderProps, SliderState> {
static defaultProps = {
prefixCls: 'ant-slider',
tooltipPrefixCls: 'ant-tooltip',
tipFormatter(value) {
tipFormatter(value: number) {
return value.toString();
},
};
constructor(props) {
constructor(props: SliderProps) {
super(props);
this.state = {
visibles: {},
};
}
toggleTooltipVisible = (index, visible) => {
toggleTooltipVisible = (index: number, visible: boolean) => {
this.setState(({ visibles }) => ({
visibles: {
...visibles,
@ -58,14 +69,15 @@ export default class Slider extends React.Component<SliderProps, any> {
},
}));
}
handleWithTooltip = ({ value, dragging, index, ...restProps }) => {
handleWithTooltip: HandleGeneratorFn = ({ value, dragging, index, ...restProps }) => {
const { tooltipPrefixCls, tipFormatter } = this.props;
const { visibles } = this.state;
const visible = tipFormatter ? (visibles[index] || dragging) : false;
return (
<Tooltip
prefixCls={tooltipPrefixCls}
title={tipFormatter ? tipFormatter(value) : ''}
visible={tipFormatter && (visibles[index] || dragging)}
visible={visible}
placement="top"
transitionName="zoom-down"
key={index}

View File

@ -16,7 +16,12 @@ export interface SpinProps {
indicator?: React.ReactNode;
}
export default class Spin extends React.Component<SpinProps, any> {
export interface SpinState {
spinning?: boolean;
notCssAnimationSupported?: boolean;
}
export default class Spin extends React.Component<SpinProps, SpinState> {
static defaultProps = {
prefixCls: 'ant-spin',
spinning: true,
@ -36,7 +41,7 @@ export default class Spin extends React.Component<SpinProps, any> {
debounceTimeout: number;
delayTimeout: number;
constructor(props) {
constructor(props: SpinProps) {
super(props);
const spinning = props.spinning;
this.state = {
@ -66,7 +71,7 @@ export default class Spin extends React.Component<SpinProps, any> {
}
}
componentWillReceiveProps(nextProps) {
componentWillReceiveProps(nextProps: SpinProps) {
const currentSpinning = this.props.spinning;
const spinning = nextProps.spinning;
const { delay } = this.props;

View File

@ -15,7 +15,7 @@ export interface SwitchProps {
disabled?: boolean;
}
export default class Switch extends React.Component<SwitchProps, any> {
export default class Switch extends React.Component<SwitchProps, {}> {
static defaultProps = {
prefixCls: 'ant-switch',
};
@ -28,7 +28,7 @@ export default class Switch extends React.Component<SwitchProps, any> {
className: PropTypes.string,
};
private rcSwitch: any;
private rcSwitch: typeof RcSwitch;
focus() {
this.rcSwitch.focus();
@ -38,7 +38,7 @@ export default class Switch extends React.Component<SwitchProps, any> {
this.rcSwitch.blur();
}
saveSwitch = (node) => {
saveSwitch = (node: typeof RcSwitch) => {
this.rcSwitch = node;
}

View File

@ -62,6 +62,12 @@ declare module 'rc-queue-anim';
declare module 'rc-slider';
declare module 'rc-slider/lib/Slider';
declare module 'rc-slider/lib/Range';
declare module 'rc-slider/lib/Handle';
declare module 'rc-steps';
declare module 'rc-switch';