我正在使用react-datetime
一个反应打字稿项目。我得到 TS2769 编译错误”
TS2769: No overload matches this call.
Overload 1 of 2, '(props: Readonly<DatetimepickerProps>): ReactDatetimeClass', gave the following error.
Type '(inputDate: Moment) => void' is not assignable to type 'EventOrValueHandler<ChangeEvent<any>>'.
Types of parameters 'inputDate' and 'event' are incompatible.
Type 'string | Moment | ChangeEvent<any>' is not assignable to type 'Moment'.
Type 'string' is not assignable to type 'Moment'.
Overload 2 of 2, '(props: DatetimepickerProps, context?: any): ReactDatetimeClass', gave the following error.
Type '(inputDate: Moment) => void' is not assignable to type 'EventOrValueHandler<ChangeEvent<any>>'.
以下是我的代码:
...
handleDateChange(inputdate: moment.Moment) {
....
}
<DateTime
timeFormat={false}
viewMode="days"
closeOnSelect
closeOnTab
required
onChange={this.handleDateChange}
/>
我不确定如何声明类型正确以使其编译。有什么可以帮忙的吗?