From 2f61e41d0d7a03976abbe9347ab8aabc7dd3fe4e Mon Sep 17 00:00:00 2001 From: Arthur Lempereur Date: Thu, 23 Oct 2025 15:01:17 +0200 Subject: [PATCH] fix: resolve TypeScript type error in formatDate function - Changed formatOptions typing to Record - Separated object creation from indexing to fix type inference - Resolves incompatible type assignment for DateTimeFormatOptions --- src/utils/helpers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 1604c92..3b47988 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -19,13 +19,13 @@ export const formatDate = ( date: Date, format: 'short' | 'medium' | 'long' = 'medium' ): string => { - const options: Intl.DateTimeFormatOptions = { + const formatOptions: Record = { short: { day: '2-digit', month: '2-digit', year: 'numeric' }, medium: { day: '2-digit', month: 'short', year: 'numeric' }, long: { day: '2-digit', month: 'long', year: 'numeric' } - }[format]; + }; - return new Intl.DateTimeFormat('fr-FR', options).format(date); + return new Intl.DateTimeFormat('fr-FR', formatOptions[format]).format(date); }; /**