Argument of type `"quarter"` | `"isoWeek"` is not assignable to parameter of type 'DurationUnitType'
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Typescript complains that `"quarter"` and `"isoWeek"` are not assignable to parameter of type `DurationUnitType` when using the `isoWeek` and `quarterOfYear` in combination with `duration`:
```ts
import dayjs from 'dayjs'
import isoWeek from 'dayjs/plugin/isoWeek'
import duration from 'dayjs/plugin/duration'
import quarterOfYear from 'dayjs/plugin/quarterOfYear'
dayjs.extend(duration)
dayjs.extend(quarterOfYear)
dayjs.extend(isoWeek)
dayjs.duration(1, 'quarter') // Argument of type '"quarter"' is not assignable to parameter of type 'DurationUnitType | undefined' ts 2345
dayjs.duration(1, 'isoWeek') // Argument of type '"isoWeek"' is not assignable to parameter of type 'DurationUnitType | undefined' ts 2345
```
**Expected behavior**
Plugin `isoWeek` and `quarterOfYear` to extend the expected input types of `dayjs.duration()`
**Information**
- Day.js Version v1.11.10
- Typescript v5.3.3
Possibly related to #1354, @zardoy?
Contributor guide
Research direction
Start by locating the type declarations for the duration, isoWeek, and quarterOfYear plugins, then reproduce the TypeScript example from the issue. Done means the example accepts both "quarter" and "isoWeek" as inputs to dayjs.duration().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100