Skip to content

Commit

Permalink
Fix implicit any for Select Slider Spin Switch
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Nov 21, 2017
1 parent 5cb5a2a commit b647078
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
6 changes: 3 additions & 3 deletions components/select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>;

Expand All @@ -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 = '',
Expand Down
24 changes: 18 additions & 6 deletions components/slider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,38 +41,43 @@ 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,
[index]: visible,
},
}));
}
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}
Expand Down
11 changes: 8 additions & 3 deletions components/spin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions components/switch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
Expand All @@ -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();
Expand All @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions typings/custom-typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit b647078

Please sign in to comment.