Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript: How to say a variable is of type moment?

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?

like image 838
aks Avatar asked Jul 14 '17 08:07

aks


1 Answers

According to moment.d.ts

import * as moment from 'moment';

interface IProps {
  callback: (startDate: moment.Moment, endDate: moment.Moment) => void
}
like image 184
Numé Avatar answered Nov 14 '22 22:11

Numé