From bae1131bd0c9fbf5e197f24e49930666f6455289 Mon Sep 17 00:00:00 2001 From: Jan Amann Date: Mon, 3 Feb 2025 16:18:50 +0100 Subject: [PATCH] feat: Use overloads for `relativeTime` --- packages/use-intl/src/core/createFormatter.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/use-intl/src/core/createFormatter.tsx b/packages/use-intl/src/core/createFormatter.tsx index bcbdb2268..a14ecaa55 100644 --- a/packages/use-intl/src/core/createFormatter.tsx +++ b/packages/use-intl/src/core/createFormatter.tsx @@ -275,6 +275,15 @@ export default function createFormatter(props: Props) { /** The date time that needs to be formatted. */ date: number | Date, /** The reference point in time to which `date` will be formatted in relation to. If this value is absent, a globally configured `now` value or alternatively the current time will be used. */ + now?: RelativeTimeFormatOptions['now'] + ): string; + function relativeTime( + /** The date time that needs to be formatted. */ + date: number | Date, + options?: RelativeTimeFormatOptions + ): string; + function relativeTime( + date: number | Date, nowOrOptions?: RelativeTimeFormatOptions['now'] | RelativeTimeFormatOptions ) { try {