Replies: 1 comment 1 reply
-
Hi @dbrxnds! Yep, the return type became more complex with the introduction of typed namespaces and message keys. I'd be curious why you're wrapping the hook in the first place? Is there anything the library could support better? Practically exporting the return type is a bit difficult and I've chosen not to pursue this further for now: #92. If there's no way for you to not wrap the hook, you might want to cast the return type to a simpler type, but then you can't take advantage of the type safety / autocompletion for namespaces and message keys. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! Would it be possible to export the type of the object/function returned by the
useTranslations
hook?We consume the
useTranslations
hook in a customuseI18n
hook in our codebase which in turn returns some extra utility stuff required to localize our app. This allows us to have all i18n related stuff in one hook.We used to just do
type tObj = ReturnType<typeof useTranslations>
but this broke in 2.7.4 as for some reason the type becomes<NestedKey=never extends NamespaceKeys..
rather than<NestedKey=any extends NamespaceKeys...
which it actually is.Any other solution would be greatly appreciated as well.
Reproduction:
https://codesandbox.io/s/awesome-bassi-372rsl?file=/src/App.tsx
I am aware that this reproduction uses a regular React project, but it's just a type issue.
Beta Was this translation helpful? Give feedback.
All reactions