TypeScript definitions for utc plugin are out of sync with runtime behavior
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
I hate to pile on as I can see you already have quite a backlog of issues, but as a TypeScript user I have been frustrated by the TypeScript definitions for the utc plugin. For example, this seems to work as expected at runtime:
```ts
const date = new Date();
const utc = dayjs.utc([date.year(), date.month() + 1, date.date()])
```
but results in a TypeScript build error:
```
TS2345: Argument of type 'number[]' is not assignable to parameter of type 'string | number | Dayjs | Date'. Type 'number[]' is missing the following properties from type 'Dayjs': clone, isValid, year, month, and 24 more
```
Why am I passing an array? Because I want to construct a utc instance from year, month and day, and I can't get anything else to work properly.
**Information**
- Day.js Version [e.g. v1.11.7]
- OS: n/a
- Browser [e.g. chrome 62]: n/a
- Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)]: n/a
Contributor guide
Research direction
Start at the utc plugin entry point and compare the runtime constructor behavior with its TypeScript definitions. Reproduce the reported array-input example, then update the definitions so the demonstrated call type-checks and verify that the existing accepted inputs remain valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100