refine icon indicating copy to clipboard operation
refine copied to clipboard

[BUG] Inconsistent `getLocale` return type (`string | undefined`)

Open codercody opened this issue 5 months ago • 3 comments

Why does getLocale have return type () => string | undefined in useTranslation if getLocale has type () => string in i18nProvider?

https://github.com/refinedev/refine/blob/39dff272c20c04efaa91d1bf35b08e078465db72/packages/core/src/hooks/i18n/useGetLocale.ts#L5

https://github.com/refinedev/refine/blob/39dff272c20c04efaa91d1bf35b08e078465db72/packages/core/src/contexts/i18n/types.ts#L12

It's annoying having to say const locale = getLocale() || "en" or const locale = getLocale()! when we already know the return type will be string.

codercody avatar May 24 '25 17:05 codercody