I have an interface which has a callback and it takes two parameters which are moment object. Here is how it looks like
interface IProps {
callback: (startDate: any, endDate: any) => void
}
This is working for me but I want to be more specific and say that they are not any but moment like so which results in an error:
interface IProps {
callback: (startDate: moment, endDate: moment) => void
}
How can I fix this?
I have an interface which has a callback and it takes two parameters which are moment object. Here is how it looks like
interface IProps {
callback: (startDate: any, endDate: any) => void
}
This is working for me but I want to be more specific and say that they are not any but moment like so which results in an error:
interface IProps {
callback: (startDate: moment, endDate: moment) => void
}
How can I fix this?
Share Improve this question edited Aug 16, 2017 at 5:38 Numé 3291 silver badge7 bronze badges asked Jul 14, 2017 at 8:13 aksaks 9,49111 gold badges52 silver badges81 bronze badges 1- what's the moment interface supposed to be? where is it defined? – toskv Commented Jul 14, 2017 at 8:14
2 Answers
Reset to default 16According to moment.d.ts
import * as moment from 'moment';
interface IProps {
callback: (startDate: moment.Moment, endDate: moment.Moment) => void
}
Import the moment
interface/class to your file with:
import { moment } from "moment";