Fix props callbacks. Type dates as moment.Moment.

This commit is contained in:
John
2017-01-20 10:58:59 -06:00
parent 08d1ef6bdd
commit 6b1b8e745c
2 changed files with 14 additions and 13 deletions

View File

@@ -3,9 +3,10 @@
// Definitions by: Rajab Shakirov <https://github.com/radziksh>, Andrey Balokha <https://github.com/andrewBalekha>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="react"/>
declare module "react-datepicker" {
import * as React from "react";
import * as moment from "moment";
interface ReactDatePickerProps {
autoComplete?: string;
autoFocus?: boolean;
@@ -14,7 +15,7 @@ declare module "react-datepicker" {
dateFormat?: string;
dateFormatCalendar?: string;
disabled?: boolean;
endDate?: {};
endDate?: moment.Moment;
excludeDates?: any[];
filterDate?(): any;
fixedHeight?: boolean;
@@ -22,12 +23,12 @@ declare module "react-datepicker" {
includeDates?: any[];
isClearable?: boolean;
locale?: string;
maxDate?: {};
minDate?: {};
maxDate?: moment.Moment;
minDate?: moment.Moment;
name?: string;
onBlur?(handler: (e: any) => void): any;
onChange(handler: (date?: any, e?: any) => void): any;
onFocus?(handler: (e: any) => void): any;
onBlur?(event: React.FocusEvent<HTMLInputElement>): void;
onChange(date: moment.Moment | null, event: React.SyntheticEvent<any> | undefined): any;
onFocus?(event: React.FocusEvent<HTMLInputElement>): void;
peekNextMonth?: boolean;
placeholderText?: string;
popoverAttachment?: string;
@@ -37,13 +38,13 @@ declare module "react-datepicker" {
renderCalendarTo?: any;
required?: boolean;
scrollableYearDropdown?: boolean;
selected?: {};
selected?: moment.Moment | null;
selectsEnd?: boolean;
selectsStart?: boolean;
showMonthDropdown?: boolean;
showYearDropdown?: boolean;
showWeekNumbers?: boolean;
startDate?: {};
startDate?: moment.Moment;
tabIndex?: number;
tetherConstraints?: any[];
title?: string;

View File

@@ -2,8 +2,8 @@ import * as React from "react";
import * as moment from 'moment';
import * as DatePicker from 'react-datepicker';
class ReactDatePicker extends React.Component<{}, {startDate:any,displayName:string}> {
constructor(props:any) {
class ReactDatePicker extends React.Component<{}, { startDate: moment.Moment; displayName:string; }> {
constructor(props: {}) {
super();
this.state = {
startDate: moment(),
@@ -12,7 +12,7 @@ class ReactDatePicker extends React.Component<{}, {startDate:any,displayName:str
this.handleChange = this.handleChange.bind(this);
}
handleChange = function(date?:any) {
handleChange = function(date?: moment.Moment | null) {
this.setState({
startDate: date
});