react-i18next: Return type problem
🐛 Bug Report
Upon updating to 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
or string | 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
- runtime version: node v16
- i18next version: v12.0.0
- os: Mac
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (6 by maintainers)
Hey @eiskalteschatten,
I had the same issue and what worked for me was putting the override in my
i18n.ts
file like so:https://www.i18next.com/overview/typescript#argument-of-type-defaulttfuncreturn-is-not-assignable-to-parameter-of-type-xyz
Why is this ticket closed, it’s still an issue?
@millar,
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
i18n.ts
file fixed the issue when adding ai18next.d.ts
file with the same content didn’t?Hey @millar,
Thanks for the example. That worked wonderfully for me!