iamkun / iamkun/dayjs

DayJS UTC Typescript issue: Expected 0 arguments, but got 1

Open
#2,387 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

Hello! I have same error as in https://github.com/iamkun/dayjs/issues/1014
"TS2554: Expected 0 arguments, but got 1." and "TS2339: Property 'add' does not exist on type 'number'."
**but only in `.test` files**

```
import dayjs, { Dayjs } from 'dayjs';
const maxEndingTime: Dayjs = dayjs().utcOffset(180).add(480, 'minutes');
```
in `..\src\entry\dayjs.ts`
```
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
dayjs.extend(utc);
```

**Information**
- Day.js Version v1.11.9 (latest)

workaround is to add this line to `.test` file:
```
import utc from 'dayjs/plugin/utc';
```

Contributor guide

Open the contributing guide

Research direction

Start with src/entry/dayjs.ts and the affected .test file, comparing how the utc plugin is imported and extended in each context. Reproduce the TypeScript errors with the shown utcOffset and add calls; done means the test code type-checks without the workaround import and relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.