diff --git a/components/date-picker/createPicker.tsx b/components/date-picker/createPicker.tsx index 6940e1bf9f..d34fd5d59a 100644 --- a/components/date-picker/createPicker.tsx +++ b/components/date-picker/createPicker.tsx @@ -6,6 +6,11 @@ import classNames from 'classnames'; import assign from 'object-assign'; import Icon from '../icon'; +export interface PickerProps { + parseDateFromValue?: Function; + value?: string | Date; +} + export default function createPicker(TheCalendar) { // use class typescript error const CalenderWrapper = React.createClass({ @@ -16,7 +21,7 @@ export default function createPicker(TheCalendar) { }; }, - componentWillReceiveProps(nextProps) { + componentWillReceiveProps(nextProps: PickerProps) { if ('value' in nextProps) { this.setState({ value: nextProps.parseDateFromValue(nextProps.value), diff --git a/components/date-picker/index.tsx b/components/date-picker/index.tsx index 4a94ce8281..108cc7824e 100644 --- a/components/date-picker/index.tsx +++ b/components/date-picker/index.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import assign from 'object-assign'; import RcCalendar from 'rc-calendar'; import MonthCalendar from 'rc-calendar/lib/MonthCalendar'; import createPicker from './createPicker'; @@ -38,9 +39,11 @@ export interface RangePickerProps extends PickerProps { onChange?: (dates: [Date, Date], dateStrings: [String, String]) => void; showTime?: TimePickerProps; } -DatePicker.RangePicker = wrapPicker(RangePicker) as React.ClassicComponentClass; -DatePicker.Calendar = Calendar; -DatePicker.MonthPicker = MonthPicker; +assign(DatePicker, { + RangePicker: wrapPicker(RangePicker) as React.ClassicComponentClass, + Calendar, + MonthPicker, +}); export default DatePicker;