From 2ac7853030ed6cca2d8450dabaa654039f11914a Mon Sep 17 00:00:00 2001 From: Ben Saufley Date: Tue, 6 Feb 2024 21:13:54 -0500 Subject: [PATCH] fix: Improve typing for min/max No null if at least one date is passed; only null if explicitly no dates are passed. --- 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 }