mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
Fix implicit any error for DatePicker
This commit is contained in:
parent
93fcbdf334
commit
9fd3588ac4
@ -32,7 +32,7 @@ function pickerValueAdapter(value?: moment.Moment | moment.Moment[]): moment.Mom
|
||||
return [value, value.clone().add(1, 'month')];
|
||||
}
|
||||
|
||||
function isEmptyArray(arr) {
|
||||
function isEmptyArray(arr: any) {
|
||||
if (Array.isArray(arr)) {
|
||||
return arr.length === 0 || arr.every(i => !i);
|
||||
}
|
||||
@ -46,7 +46,7 @@ export default class RangePicker extends React.Component<any, any> {
|
||||
showToday: false,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
const value = props.value || props.defaultValue || [];
|
||||
if (
|
||||
@ -67,7 +67,7 @@ export default class RangePicker extends React.Component<any, any> {
|
||||
};
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
componentWillReceiveProps(nextProps: any) {
|
||||
if ('value' in nextProps) {
|
||||
const state = this.state;
|
||||
const value = nextProps.value || [];
|
||||
@ -83,7 +83,7 @@ export default class RangePicker extends React.Component<any, any> {
|
||||
}
|
||||
}
|
||||
|
||||
clearSelection = (e) => {
|
||||
clearSelection = (e: React.MouseEvent<HTMLElement>) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.setState({ value: [] });
|
||||
@ -106,7 +106,7 @@ export default class RangePicker extends React.Component<any, any> {
|
||||
]);
|
||||
}
|
||||
|
||||
handleOpenChange = (open) => {
|
||||
handleOpenChange = (open: boolean) => {
|
||||
if (!('open' in this.props)) {
|
||||
this.setState({ open });
|
||||
}
|
||||
@ -117,18 +117,18 @@ export default class RangePicker extends React.Component<any, any> {
|
||||
}
|
||||
}
|
||||
|
||||
handleShowDateChange = showDate => this.setState({ showDate });
|
||||
handleShowDateChange = (showDate: boolean) => this.setState({ showDate });
|
||||
|
||||
handleHoverChange = hoverValue => this.setState({ hoverValue });
|
||||
handleHoverChange = (hoverValue: any) => this.setState({ hoverValue });
|
||||
|
||||
setValue(value, hidePanel?) {
|
||||
setValue(value: moment.Moment[], hidePanel?: boolean) {
|
||||
this.handleChange(value);
|
||||
if ((hidePanel || !this.props.showTime) && !('open' in this.props)) {
|
||||
this.setState({ open: false });
|
||||
}
|
||||
}
|
||||
|
||||
renderFooter = (...args) => {
|
||||
renderFooter = (...args: any[]) => {
|
||||
const { prefixCls, ranges, renderExtraFooter } = this.props;
|
||||
if (!ranges && !renderExtraFooter) {
|
||||
return null;
|
||||
@ -243,7 +243,7 @@ export default class RangePicker extends React.Component<any, any> {
|
||||
/>
|
||||
) : null;
|
||||
|
||||
const input = ({ value: inputValue }) => {
|
||||
const input = ({ value: inputValue }: { value: any }) => {
|
||||
const start = inputValue[0];
|
||||
const end = inputValue[1];
|
||||
return (
|
||||
|
@ -5,7 +5,7 @@ import RcDatePicker from 'rc-calendar/lib/Picker';
|
||||
import classNames from 'classnames';
|
||||
import Icon from '../icon';
|
||||
|
||||
function formatValue(value: moment.Moment | undefined, format: string): string {
|
||||
function formatValue(value: moment.Moment | null, format: string): string {
|
||||
return (value && value.format(format)) || '';
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ export default class WeekPicker extends React.Component<any, any> {
|
||||
format: 'YYYY-Wo',
|
||||
allowClear: true,
|
||||
};
|
||||
constructor(props) {
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
const value = props.value || props.defaultValue;
|
||||
if (value && !moment.isMoment(value)) {
|
||||
@ -27,12 +27,12 @@ export default class WeekPicker extends React.Component<any, any> {
|
||||
value,
|
||||
};
|
||||
}
|
||||
componentWillReceiveProps(nextProps) {
|
||||
componentWillReceiveProps(nextProps: any) {
|
||||
if ('value' in nextProps) {
|
||||
this.setState({ value: nextProps.value });
|
||||
}
|
||||
}
|
||||
weekDateRender = (current) => {
|
||||
weekDateRender = (current: any) => {
|
||||
const selectedValue = this.state.value;
|
||||
const { prefixCls } = this.props;
|
||||
if (selectedValue &&
|
||||
@ -52,13 +52,13 @@ export default class WeekPicker extends React.Component<any, any> {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
handleChange = (value) => {
|
||||
handleChange = (value: moment.Moment | null) => {
|
||||
if (!('value' in this.props)) {
|
||||
this.setState({ value });
|
||||
}
|
||||
this.props.onChange(value, formatValue(value, this.props.format));
|
||||
}
|
||||
clearSelection = (e) => {
|
||||
clearSelection = (e: React.MouseEvent<HTMLElement>) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.handleChange(null);
|
||||
@ -96,7 +96,7 @@ export default class WeekPicker extends React.Component<any, any> {
|
||||
onClick={this.clearSelection}
|
||||
/>
|
||||
) : null;
|
||||
const input = ({ value }) => {
|
||||
const input = ({ value }: { value: moment.Moment | undefined }) => {
|
||||
return (
|
||||
<span>
|
||||
<input
|
||||
|
@ -13,7 +13,7 @@ export interface PickerProps {
|
||||
prefixCls: string;
|
||||
}
|
||||
|
||||
export default function createPicker(TheCalendar): any {
|
||||
export default function createPicker(TheCalendar: React.ComponentClass): any {
|
||||
return class CalenderWrapper extends React.Component<any, any> {
|
||||
static defaultProps = {
|
||||
prefixCls: 'ant-calendar',
|
||||
@ -21,7 +21,7 @@ export default function createPicker(TheCalendar): any {
|
||||
showToday: true,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
const value = props.value || props.defaultValue;
|
||||
if (value && !moment.isMoment(value)) {
|
||||
@ -43,7 +43,7 @@ export default function createPicker(TheCalendar): any {
|
||||
}
|
||||
}
|
||||
|
||||
renderFooter = (...args) => {
|
||||
renderFooter = (...args: any[]) => {
|
||||
const { prefixCls, renderExtraFooter } = this.props;
|
||||
return renderExtraFooter ? (
|
||||
<div className={`${prefixCls}-footer-extra`}>
|
||||
@ -52,13 +52,13 @@ export default function createPicker(TheCalendar): any {
|
||||
) : null;
|
||||
}
|
||||
|
||||
clearSelection = (e) => {
|
||||
clearSelection = (e: React.MouseEvent<HTMLElement>) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.handleChange(null);
|
||||
}
|
||||
|
||||
handleChange = (value) => {
|
||||
handleChange = (value: moment.Moment | null) => {
|
||||
const props = this.props;
|
||||
if (!('value' in props)) {
|
||||
this.setState({ value });
|
||||
@ -127,7 +127,7 @@ export default function createPicker(TheCalendar): any {
|
||||
/>
|
||||
) : null;
|
||||
|
||||
const input = ({ value: inputValue }) => (
|
||||
const input = ({ value: inputValue }: { value: moment.Moment | null }) => (
|
||||
<div>
|
||||
<input
|
||||
disabled={props.disabled}
|
||||
|
@ -6,7 +6,7 @@ import { generateShowHourMinuteSecond } from '../time-picker';
|
||||
import warning from '../_util/warning';
|
||||
declare const require: Function;
|
||||
|
||||
function getColumns({ showHour, showMinute, showSecond, use12Hours }) {
|
||||
function getColumns({ showHour, showMinute, showSecond, use12Hours }: any) {
|
||||
let column = 0;
|
||||
if (showHour) {
|
||||
column += 1;
|
||||
@ -23,7 +23,7 @@ function getColumns({ showHour, showMinute, showSecond, use12Hours }) {
|
||||
return column;
|
||||
}
|
||||
|
||||
export default function wrapPicker(Picker, defaultFormat?: string): any {
|
||||
export default function wrapPicker(Picker: React.ComponentClass<any>, defaultFormat?: string): any {
|
||||
return class PickerWrapper extends React.Component<any, any> {
|
||||
static defaultProps = {
|
||||
format: defaultFormat || 'YYYY-MM-DD',
|
||||
@ -40,7 +40,7 @@ export default function wrapPicker(Picker, defaultFormat?: string): any {
|
||||
inputPrefixCls: 'ant-input',
|
||||
};
|
||||
|
||||
handleOpenChange = (open) => {
|
||||
handleOpenChange = (open: boolean) => {
|
||||
const { onOpenChange, toggleOpen } = this.props;
|
||||
onOpenChange(open);
|
||||
|
||||
@ -59,7 +59,7 @@ export default function wrapPicker(Picker, defaultFormat?: string): any {
|
||||
return locale.default || locale;
|
||||
}
|
||||
|
||||
renderPicker = (locale, localeCode) => {
|
||||
renderPicker = (locale: any, localeCode: string) => {
|
||||
const props = this.props;
|
||||
const { prefixCls, inputPrefixCls } = props;
|
||||
const pickerClass = classNames(`${prefixCls}-picker`, {
|
||||
|
Loading…
Reference in New Issue
Block a user