minMax return a unexpected value
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
```
dayjs.max('2021-01-01', dayjs('2020-01-01')) // => '2021-01-01'
dayjs.max('2020-01-01', dayjs('2021-01-01')) // => dayjs('2021-01-01')
dayjs.max(dayjs('2021-01-01'), '2020-01-01') // => TypeError: n[r].isValid is not a function
```
but in the minMax.d.ts :
```
declare module 'dayjs' {
export function max(dayjs: Dayjs[]): Dayjs
export function max(...dayjs: Dayjs[]): Dayjs
export function min(dayjs: Dayjs[]): Dayjs
export function min(...dayjs: Dayjs[]): Dayjs
}
```
**Expected behavior**
```
dayjs.max('2021-01-01', dayjs('2020-01-01')) // => dayjs('2021-01-01')
dayjs.max('2020-01-01', dayjs('2021-01-01')) // => dayjs('2021-01-01')
dayjs.max(dayjs('2021-01-01'), '2020-01-01') // => dayjs('2021-01-01')
```
or
```
dayjs.max('2021-01-01', dayjs('2020-01-01')) // => TypeError: '2021-01-01' is not a instance of Dayjs
dayjs.max('2020-01-01', dayjs('2021-01-01')) // => TypeError: '2021-01-01' is not a instance of Dayjs
dayjs.max(dayjs('2021-01-01'), '2020-01-01') // => TypeError '2020-01-01' is not a instance of Dayjs
```
**Information**
- Day.js Version [e.g. v1.0.0]
- OS: any
- Browser: any
- Time zone: any
Contributor guide
Research direction
Start at the dayjs.max/minMax entry point and inspect the minMax.d.ts declarations mentioned in the issue. Reproduce the three mixed string and Dayjs calls, then clarify whether mixed inputs should be accepted or rejected before aligning the behavior and declarations and adding coverage for the chosen contract.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100