Skip to content

Commit

Permalink
Improve typing for min/max
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.
  • Loading branch information
bensaufley committed Feb 7, 2024
1 parent bdcc336 commit 3dd0b6a
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 3dd0b6a

Please sign in to comment.