From 21e51d128dd3ecfe63fb4be288f8eadf57aff9da Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 9 Nov 2023 11:35:06 +0800 Subject: [PATCH] chore(i18n): resolve ts type error --- src/hooks/web/useI18n.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hooks/web/useI18n.ts b/src/hooks/web/useI18n.ts index e5e9d043..3906cf7e 100644 --- a/src/hooks/web/useI18n.ts +++ b/src/hooks/web/useI18n.ts @@ -38,9 +38,14 @@ export function useI18n(namespace?: string): { const tFn: I18nGlobalTranslation = (key: string, ...arg: any[]) => { if (!key) return '' + if (!key.includes('.') && !namespace) return key - return t(getKey(namespace, key), ...(arg as I18nTranslationRestParameters)) + + return (t as (arg0: string, ...arg: I18nTranslationRestParameters) => string)( + getKey(namespace, key), + ...(arg as I18nTranslationRestParameters), + ) } return { ...methods,