HumanizeDuration.ts
HumanizeDuration.ts copied to clipboard
Typescript warning when using HumanizeDuration
import { HumanizeDuration } from 'humanize-duration-ts'
...
const durationStr: string = HumanizeDuration(1000)
The above code results in the following error:
@typescript-eslint/no-unsafe-assignment: Unsafe assignment of an any value.
Version:
humanize-duration-ts@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/humanize-duration-ts/-/humanize-duration-ts-2.1.1.tgz#5382b2789f851005a67229eaf031931d71f37ee9"
integrity sha512-TibNF2/fkypjAfHdGpWL/dmWUS0G6Qi+3mKyiB6LDCowbMy+PtzbgPTnFMNTOVAJXDau01jYrJ3tFoz5AJSqhA==
Oh, I guess I haven't RTFM it...
import { HumanizeDurationLanguage, HumanizeDuration } from 'humanize-duration-ts'
const langService: HumanizeDurationLanguage = new HumanizeDurationLanguage()
const humanizer = new HumanizeDuration(langService)
...
const durationStr: string = humanizer.humanize(1000)
Maybe turn this issue into a feature request to support a short notation, i.e. to allow writing the above code in the abbreviated form of (assuming default language):
import { HumanizeDuration } from 'humanize-duration-ts'
...
const durationStr: string = HumanizeDuration(1000)