In my TypeScript (Ionic2/Angular2) project, I have incorporated moment.js. After reading through this post, I decided to experiment with a plugin called moment-duration-format
With the npm package and type definition installed, I can use it by importing as..
import moment from 'moment';
...
let duration = moment.duration(decimalHours, 'hours');
Now, I want to dive into using moment-duration-format
I went ahead and installed it using
npm install moment-duration-format --save
followed by adding the type definition with npm i @types/moment-duration-format --save
.
Both npm modules are in place.
However, there seems to be some confusion on how to actually utilize these type definitions (the documentation lacks clarity on this aspect).
I attempted to add import 'moment-duration-format';
and
import duration from 'moment-duration-format';
but encountered errors as such..
let dd = moment.duration.format(400.99, 'hours').format('D:HH:mm');
// Error - Property 'format' does not exist on type '(inp?: DurationInputArg1, unit?: DurationConstructor) => Duration'.
If anyone has insights on how to effectively leverage this in TypeScript, your help would be greatly appreciated.
Thank you in advance