-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Return type problem #1587
Comments
Sorry my bad. I had to restart the IDE to reload the configurations. |
I have been trying to solve this problem all day in my project, but when I follow the instructions linked above, I get these errors:
Apparently, I'm missing something since it seems to override all of i18next's typings rather than merge with them. Any ideas? For now, I'm going to have downgrade and keep i18next at a fixed version. This is the |
Hey @eiskalteschatten, I had the same issue and what worked for me was putting the override in my import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
declare module 'i18next' {
interface CustomTypeOptions {
returnNull: false;
}
}
i18n
.use(initReactI18next)
.init({
returnNull: false,
});
export default i18n; |
Hey @millar, Thanks for the example. That worked wonderfully for me! |
Thank you for that example. Worked for me as well. The thing that bothers me now is I don't know why that worked! Can anyone explain why that putting the override in the |
I'm not sure, but maybe it's because override from separate file isn't reading in proper order to apply |
I don't have any i18n.ts file? Using next.js ... |
Why is this ticket closed, it's still an issue? |
I can't get it to work either ... |
did you set returnNull: false ? |
Yeah, I've done it for both |
please provide a minimal reproducible example repository btw: you need to define that in the i18next options and in the i18next type definitions, nit in the compiler options |
As I've said, that doesn't fix it. |
@marcus-sa like said: please provide a minimal reproducible example so that can be investigated, like here: https://github.com/i18next/react-i18next/tree/master/example/react-typescript/simple especially:
and: https://github.com/i18next/react-i18next/blob/master/example/react-typescript/simple/src/i18n/config.ts#L17 beside that, @pedrodurek is currently working on a redesign: i18next/i18next#1911 |
🐛 Bug Report
Upon updating to
![image](https://user-images.githubusercontent.com/21160900/204221870-84aaa9f4-6a64-4ae0-897d-1c547d8e822a.png)
v12.0.0
return type issue appears as follows:As you can see, explicitly defining the return type to
string | undefined
shows an error. But defining the type as string alone doesn't show any error.Compare that with explicitly defining the value as below, the behavior sounds weird to me.
As you can see here, if the type is
string
orstring | undefined
and the value is null, the error appears (expected).Expected behavior
string | undefined
return type should work without issues as it was before updating to v12.0.0.Your Environment
The text was updated successfully, but these errors were encountered: