As per documentation ant design 4.7
onChange Callback function, can be executed when the selected time is changing function(dates: [moment, moment], dateStrings: [string, string])
Error
Type '(date: Array<Moment>, dateString: Array<string>) => void' is not assignable to type '(values: RangeValue<Moment>, formatString: [string, string]) => void'.
Types of parameters 'date' and 'values' are incompatible.
Type 'RangeValue<Moment>' is not assignable to type 'Moment[]'.
Type 'null' is not assignable to type 'Moment[]'.
Code
const dateTimeOnChange = (
date: Array<Moment>,
dateString: Array<string>
): void => {
console.log(date);
console.log(dateString);
};
Can't find type definition for and design RangePicker onChange 1st parameter type.
From the error message and the docs the problem is pretty clear. The parameters are not arbitrary length arrays, but rather fixed size arrays (aka tuples), also the
date
parameter may benull
Try
You could probably also use
date: RangeValue<Moment>
ifRangeValue
is exported from the module it is declared in.