-
-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typings are incomplete for useTranslation #766
Comments
Why are you trying to pass |
I am trying to extract/use it. It is present in |
@pixelass If you're curious, feel free to just dive into the source code. |
@isaachinman I looked through the source but it seems since Since Example: import {useTranslation as useOriginalTranslation} from `react-i18next`
export interface Options {
localeSubpaths: Record<string, string>
}
export const useTranslation = useOriginalTranslation<Options> |
Why do you need to use/inspect the i18n instance which is output by |
See: #413 (comment) const lang = Object.values(localeSubpaths).includes(language) ? language : ""; It takes care of the issue mentioned here: #764
...where not every locale is using subPaths. |
Maybe I can propose a change in the typing https://github.com/i18next/react-i18next/blob/master/src/index.d.ts#L60-L63 to allow adding some custom interface extension export function useTranslation<O>( // O was added
ns?: Namespace,
options?: UseTranslationOptions,
): UseTranslationResponse<O>; // O needs to be passed down |
It might be more complicated since We would need it to allow this: interface i18n<O = {}> {
//...
options : {/*...*/} & O
} |
You don't need to look into the output of |
I don't have access to the instance since it is defined locally. https://github.com/isaachinman/next-i18next#3-project-setup const NextI18Next = require('next-i18next').default
module.exports = new NextI18Next({
defaultLanguage: 'en',
otherLanguages: ['de']
}) I haven't tried to add it to the core but I think it will resolve once I start and take a detailed look at the core of this library. Sorry, I've had a long day and my brain doesn't seem to function that well anymore :) Just ignore it for now. I'll open a new (more precise) issue if I encounter any conflicts. |
Describe the bug
The exported
useTranslation
is not typed appropriately.TS2339: Property 'localeSubpaths' does not exist on type 'InitOptions'.
Occurs in next-i18next version
Steps to reproduce
Expected behaviour
As a developer I expect the typings to reflect the actual interfaces exposed by the methods/functions.
Screenshots
OS (please complete the following information)
Additional context
I think the
useTranslation
(re-export from react-i18next) should be exported with an extended type.The text was updated successfully, but these errors were encountered: