-
-
Notifications
You must be signed in to change notification settings - Fork 650
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
[TypeScript] Add default value for TDefaultResult #1853
[TypeScript] Add default value for TDefaultResult #1853
Conversation
thank you.... released with v22.0.2 |
Hey @adrai @pedrodurek, thanks for your amazing work 👍 I've updated
I tried to follow this documentation but since I have no workspace, I don't really now how to make it work 😅 I also tried to use
"i18next": "22.0.2",
"react-i18next": "12.0.0", |
@Erazihel until @pedrodurek is back online, you may try to provide a minimal reproducible example showing the issue. |
I have a similar issue with |
I have a similar issue:
Is there a way to disable it and to say
|
Hey @adrai 👋 I tried to reproduce the issue on a CodeSandbox without any luck. Everything works fine even though I tried to have a Sandbox as close as my current project. I don't know why but it seems that in my project the I guess it has something to do with the
I managed to force the type using Hoping that someone manages to reproduce this behaviour or that you have an idea where this could come from and a solution to this. Cheers! |
Hi! I face typings issue when using library like this (see App.tsx):
Workarounds:
PS. I know example doesn't contain i18next initialization, however wanted to use minium number of steps to reproduce - please let me know if more info is needed |
Take also a look at this: #1852 |
We have the Vite React app with @mui, and in dev mode with |
In React 18, they change the React type declaration to stop accepting object in JSX elements. Right now, there is a limitation for people who opt out following the instructions here https://www.i18next.com/overview/typescript, I'll see what I can do. In the meantime, I encourage everyone to follow the instructions in the document. Later today, I'll update |
Is it possible to get an example with a project like https://github.com/locize/react-tutorial/blob/main/step_4/src/i18n.js or https://github.com/locize/react-tutorial/blob/main/step_0/src/i18n.js |
How to handle case with translation files fetched from remote server? I don't need typed keys for translations, but only looking for way to return string from |
@pedrodurek I'm not a TypeScript user, but maybe changing this here in react-i18next would help? - type ReactI18NextChild = React.ReactNode | ObjectOrNever;
+ type ReactI18NextChild = React.ReactNode | DefaultTFuncReturn | ObjectOrNever; Issue shown in example based on your i18next-ts-issue repo: pedrodurek/i18next-ts-issue@main...adrai:i18next-ts-issue:main |
Hey @Erazihel :p |
Hey @NoZiL 😊
The link says to use |
@pedrodurek this really seems to still be a problem, can you check if my suggested change is correct? |
Declaring it like this worked for me. // References: https://www.i18next.com/overview/typescript
import "i18next";
declare module 'i18next' {
interface CustomTypeOptions {
// custom namespace type, if you changed it
defaultNS: "common";
// custom resources type
resources: {
nl: Record<string, string>;
en: Record<string, string>;
de: Record<string, string>;
fr: Record<string, string>;
};
}
} |
can you try with i18next v22.0.3? |
@adrai works for me, thank you! 🙏 |
@adrai Just tested and everything works fine once again! Thank you so much! 🙏 |
Looks like it is working also for me, thank you! ❤️ |
@adrai it worked thank you! |
Closes #1852
Checklist
npm run test
Checklist (for documentation change)