mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
Fix implicit any error for Calendar
This commit is contained in:
parent
50f85480d1
commit
f4dc69f5f0
@ -12,7 +12,7 @@ export interface HeaderProps {
|
||||
yearSelectOffset?: number;
|
||||
yearSelectTotal?: number;
|
||||
type?: string;
|
||||
onValueChange?: (value) => void;
|
||||
onValueChange?: (value: moment.Moment) => void;
|
||||
onTypeChange?: (type: string) => void;
|
||||
value: any;
|
||||
}
|
||||
@ -24,9 +24,9 @@ export default class Header extends React.Component<HeaderProps, any> {
|
||||
yearSelectTotal: 20,
|
||||
};
|
||||
|
||||
private calenderHeaderNode: any;
|
||||
private calenderHeaderNode: HTMLDivElement;
|
||||
|
||||
getYearSelectElement(year) {
|
||||
getYearSelectElement(year: number) {
|
||||
const { yearSelectOffset, yearSelectTotal, locale, prefixCls, fullscreen } = this.props;
|
||||
const start = year - (yearSelectOffset as number);
|
||||
const end = start + (yearSelectTotal as number);
|
||||
@ -61,7 +61,7 @@ export default class Header extends React.Component<HeaderProps, any> {
|
||||
return months;
|
||||
}
|
||||
|
||||
getMonthSelectElement(month, months) {
|
||||
getMonthSelectElement(month: number, months: number[]) {
|
||||
const props = this.props;
|
||||
const { prefixCls, fullscreen } = props;
|
||||
const options: React.ReactElement<any>[] = [];
|
||||
@ -84,7 +84,7 @@ export default class Header extends React.Component<HeaderProps, any> {
|
||||
);
|
||||
}
|
||||
|
||||
onYearChange = (year) => {
|
||||
onYearChange = (year: string) => {
|
||||
const newValue = this.props.value.clone();
|
||||
newValue.year(parseInt(year, 10));
|
||||
|
||||
@ -94,7 +94,7 @@ export default class Header extends React.Component<HeaderProps, any> {
|
||||
}
|
||||
}
|
||||
|
||||
onMonthChange = (month) => {
|
||||
onMonthChange = (month: string) => {
|
||||
const newValue = this.props.value.clone();
|
||||
newValue.month(parseInt(month, 10));
|
||||
const onValueChange = this.props.onValueChange;
|
||||
@ -110,7 +110,7 @@ export default class Header extends React.Component<HeaderProps, any> {
|
||||
}
|
||||
}
|
||||
|
||||
getCalenderHeaderNode = (node) => {
|
||||
getCalenderHeaderNode = (node: HTMLDivElement) => {
|
||||
this.calenderHeaderNode = node;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ export { HeaderProps } from './Header';
|
||||
|
||||
function noop() { return null; }
|
||||
|
||||
function zerofixed(v) {
|
||||
function zerofixed(v: number) {
|
||||
if (v < 10) {
|
||||
return `0${v}`;
|
||||
}
|
||||
@ -41,7 +41,7 @@ export interface CalendarProps {
|
||||
}
|
||||
|
||||
export interface CalendarState {
|
||||
value?: moment.Moment;
|
||||
value: moment.Moment;
|
||||
mode?: CalendarMode;
|
||||
}
|
||||
|
||||
@ -70,8 +70,8 @@ export default class Calendar extends React.Component<CalendarProps, CalendarSta
|
||||
onSelect: PropTypes.func,
|
||||
};
|
||||
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
constructor(props: CalendarProps) {
|
||||
super(props);
|
||||
|
||||
const value = props.value || props.defaultValue || callMoment(moment);
|
||||
if (!moment.isMoment(value)) {
|
||||
@ -89,12 +89,12 @@ export default class Calendar extends React.Component<CalendarProps, CalendarSta
|
||||
componentWillReceiveProps(nextProps: CalendarProps) {
|
||||
if ('value' in nextProps) {
|
||||
this.setState({
|
||||
value: nextProps.value,
|
||||
value: nextProps.value!,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
monthCellRender = (value) => {
|
||||
monthCellRender = (value: moment.Moment) => {
|
||||
const { prefixCls, monthCellRender = noop as Function } = this.props;
|
||||
return (
|
||||
<div className={`${prefixCls}-month`}>
|
||||
@ -108,7 +108,7 @@ export default class Calendar extends React.Component<CalendarProps, CalendarSta
|
||||
);
|
||||
}
|
||||
|
||||
dateCellRender = (value) => {
|
||||
dateCellRender = (value: moment.Moment) => {
|
||||
const { prefixCls, dateCellRender = noop as Function } = this.props;
|
||||
return (
|
||||
<div className={`${prefixCls}-date`}>
|
||||
@ -127,7 +127,7 @@ export default class Calendar extends React.Component<CalendarProps, CalendarSta
|
||||
return locale.default || locale;
|
||||
}
|
||||
|
||||
setValue = (value, way: 'select' | 'changePanel') => {
|
||||
setValue = (value: moment.Moment, way: 'select' | 'changePanel') => {
|
||||
if (!('value' in this.props)) {
|
||||
this.setState({ value });
|
||||
}
|
||||
@ -140,7 +140,7 @@ export default class Calendar extends React.Component<CalendarProps, CalendarSta
|
||||
}
|
||||
}
|
||||
|
||||
setType = (type) => {
|
||||
setType = (type: string) => {
|
||||
const mode = (type === 'date') ? 'month' : 'year';
|
||||
if (this.state.mode !== mode) {
|
||||
this.setState({ mode });
|
||||
@ -148,26 +148,26 @@ export default class Calendar extends React.Component<CalendarProps, CalendarSta
|
||||
}
|
||||
}
|
||||
|
||||
onHeaderValueChange = (value) => {
|
||||
onHeaderValueChange = (value: moment.Moment) => {
|
||||
this.setValue(value, 'changePanel');
|
||||
}
|
||||
|
||||
onHeaderTypeChange = (type) => {
|
||||
onHeaderTypeChange = (type: string) => {
|
||||
this.setType(type);
|
||||
}
|
||||
|
||||
onPanelChange(value, mode) {
|
||||
onPanelChange(value: moment.Moment, mode: CalendarMode | undefined) {
|
||||
const { onPanelChange } = this.props;
|
||||
if (onPanelChange) {
|
||||
onPanelChange(value, mode);
|
||||
}
|
||||
}
|
||||
|
||||
onSelect = (value) => {
|
||||
onSelect = (value: moment.Moment) => {
|
||||
this.setValue(value, 'select');
|
||||
}
|
||||
|
||||
renderCalendar = (locale, localeCode) => {
|
||||
renderCalendar = (locale: any, localeCode: string) => {
|
||||
const { state, props } = this;
|
||||
const { value, mode } = state;
|
||||
if (value && localeCode) {
|
||||
|
Loading…
Reference in New Issue
Block a user