fix(ui): formatDate and formatTimeToNow utility type error on i18n arg to support I18nClient too (#12576)

In one of the versions we've changed the type of the argument from
`I18n<any, any>` to `I18n<unknown, unknown>` and this has caused some
issues with TS resolving the type compatibility in the `formatDate`
utility so it no longer supports `I18nClient`.

This type change happened in
https://github.com/payloadcms/payload/pull/10030
This commit is contained in:
Paul
2025-06-03 15:30:38 -07:00
committed by GitHub
parent 30bb749e25
commit 76bf459ff2

View File

@@ -1,11 +1,11 @@
import type { I18n } from '@payloadcms/translations'
import type { I18n, I18nClient } from '@payloadcms/translations'
import { TZDateMini as TZDate } from '@date-fns/tz/date/mini'
import { format, formatDistanceToNow, transpose } from 'date-fns'
export type FormatDateArgs = {
date: Date | number | string | undefined
i18n: I18n<unknown, unknown>
i18n: I18n<unknown, unknown> | I18nClient<unknown>
pattern: string
timezone?: string
}
@@ -34,7 +34,7 @@ export const formatDate = ({ date, i18n, pattern, timezone }: FormatDateArgs): s
type FormatTimeToNowArgs = {
date: Date | number | string | undefined
i18n: I18n<unknown, unknown>
i18n: I18n<unknown, unknown> | I18nClient<unknown>
}
export const formatTimeToNow = ({ date, i18n }: FormatTimeToNowArgs): string => {