I'm trying to use "moment-duration-formation" in TypeScript but, even though it works, webpack keeps on complaining that it can't find the "format" method on the line:
return moment.duration(value, "minutes").format("...");
Here is the package.json
{
"devDependencies": {
"@types/moment-duration-format": "^1.3.7"
},
"dependencies": {
"moment": "^2.18.1",
"moment-duration-format": "^1.3.0"
}
}
And the tsconfig.json:
{
"compilerOptions": {
"typeRoots": [ "./node_modules/@types" ]
}
}
In the (angular2) component:
import * as moment from "moment";
import * as momentDurationFormat from "moment-duration-format";
...
let result: string = moment.duration(this.selectedHangarDistance * 10, "minutes").format("...")
I also tried with
import "moment-duration-format";
But it does not change anything:
ERROR in [at-loader] ./src/app/components/building/shop/shop.component.ts:190:81 TS2339: Property 'format' does not exist on type 'Duration'.
npm install --save-dev @types/moment
? – Roslynrosmarin