From 4fbe94aaba8c815a42cf4d23dabac918ec50e68c Mon Sep 17 00:00:00 2001 From: Ben Saufley Date: Mon, 20 May 2024 08:11:56 -0400 Subject: [PATCH] fix: Improve typing for min/max plugin (#2573) No null if at least one date is passed; only null if explicitly no dates are passed. Co-authored-by: iamkun --- types/plugin/minMax.d.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/types/plugin/minMax.d.ts b/types/plugin/minMax.d.ts index 4c5f6dcd7..7d0827f13 100644 --- a/types/plugin/minMax.d.ts +++ b/types/plugin/minMax.d.ts @@ -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 }