Import
import * as moment from 'moment'; import 'moment-duration-format';
Outside of your class, define the interfaces:
interface Duration extends moment.Duration { format: (template?: string, precision?: number, settings?: DurationSettings) => string; } interface DurationSettings { forceLength: boolean; precision: number; template: string; trim: boolean | 'left' | 'right'; }
Then in your code:
const duration = moment.duration(minutes, 'minutes') as Duration; return duration.format('mm');
If you defined your Duration
interface in another file, you will also need to export and import it.
source share