diff --git a/components/calendar/Header.tsx b/components/calendar/Header.tsx index e91467ca7b..39571b5c4b 100644 --- a/components/calendar/Header.tsx +++ b/components/calendar/Header.tsx @@ -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 { 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 { return months; } - getMonthSelectElement(month, months) { + getMonthSelectElement(month: number, months: number[]) { const props = this.props; const { prefixCls, fullscreen } = props; const options: React.ReactElement[] = []; @@ -84,7 +84,7 @@ export default class Header extends React.Component { ); } - 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 { } } - 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 { } } - getCalenderHeaderNode = (node) => { + getCalenderHeaderNode = (node: HTMLDivElement) => { this.calenderHeaderNode = node; } diff --git a/components/calendar/index.tsx b/components/calendar/index.tsx index 9d75f49ece..abe5250c0c 100644 --- a/components/calendar/index.tsx +++ b/components/calendar/index.tsx @@ -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 { + monthCellRender = (value: moment.Moment) => { const { prefixCls, monthCellRender = noop as Function } = this.props; return (
@@ -108,7 +108,7 @@ export default class Calendar extends React.Component { + dateCellRender = (value: moment.Moment) => { const { prefixCls, dateCellRender = noop as Function } = this.props; return (
@@ -127,7 +127,7 @@ export default class Calendar extends React.Component { + 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 { + 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 { + 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) {