Hi,
would like to use moment-duration-format extension for moment.js in an
Ionic2 app for duration formatting.
I installed moment and moment-duration-format with
npm install moment --save
npm install moment-duration-format –save
and the TypeScript definition for moment-duration-format
npm install @types/moment-duration-format --save
All core moment.js functions compile correctly, but the format function of the
moment-duration-format extension not:
import * as moment from “moment”;
import * as MomentDuration from “moment-duration-format/lib/moment-duration-format”;
…
let diff = moment(this.endTime).diff(moment(this.startTime), ‘minutes’);
let duration = moment.duration(diff, ‘minutes’).format(“h [H]”);
Error:(122, 67) TS2339:Property ‘format’ does not exist on type ‘Duration’.
I hope anybody knows how to use an moment.js extension.