Skip to content

Commit

Permalink
fix: Improve typing for min/max plugin (#2573)
Browse files Browse the repository at this point in the history
No null if at least one date is passed; only null if explicitly no dates are passed.

Co-authored-by: iamkun <[email protected]>
  • Loading branch information
bensaufley and iamkun authored May 20, 2024
1 parent 1e61e42 commit 4fbe94a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions types/plugin/minMax.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ declare const plugin: PluginFunc
export = plugin

declare module 'dayjs' {
export function max(dayjs: Dayjs[]): Dayjs | null
export function max(...dayjs: Dayjs[]): Dayjs | null
export function min(dayjs: Dayjs[]): Dayjs | null
export function min(...dayjs: Dayjs[]): Dayjs | null
export function max(dayjs: [Dayjs, ...Dayjs[]]): Dayjs
export function max(noDates: never[]): null
export function max(maybeDates: Dayjs[]): Dayjs | null

export function max(...dayjs: [Dayjs, ...Dayjs[]]): Dayjs
export function max(...noDates: never[]): null
export function max(...maybeDates: Dayjs[]): Dayjs | null

export function min(dayjs: [Dayjs, ...Dayjs[]]): Dayjs
export function min(noDates: never[]): null
export function min(maybeDates: Dayjs[]): Dayjs | null

export function min(...dayjs: [Dayjs, ...Dayjs[]]): Dayjs
export function min(...noDates: never[]): null
export function min(...maybeDates: Dayjs[]): Dayjs | null
}

0 comments on commit 4fbe94a

Please sign in to comment.