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
Change DefaultTFuncReturn
to return null
if returnNull
typeOption is true
#1865
Change DefaultTFuncReturn
to return null
if returnNull
typeOption is true
#1865
Conversation
tests are failing |
included in v22.0.5 |
Might be a dumb question but after this was included, it removed undefined as one of the possible returns of DefaultTFuncReturn, which in some cases gives an error then. For example TextInput requires either string | undefined in the placeholder, and with this update I'm getting this error:
This can be fixed by setting customTypeOptions returnNull: false, but was just wondering is that the preferred way instead of having also undefined as an option 🤔 |
Hey @Jonnboy91, // i18next.d.ts
import 'i18next';
declare module 'i18next' {
interface CustomTypeOptions {
returnNull: false;
}
} @adrai can correct if I'm wrong, but |
Hi @pedrodurek Thanks, this is what I thought and meant by "This can be fixed by setting customTypeOptions returnNull: false", but yeah it used to have the option of undefined and now that it was deleted some places where translation was used were giving errors now, but I could fix it by setting this customTypeOptions, so this was more of a question is the undefined coming back or will I just use this 💪 😄 |
Yes, I'm not aware of any use case returning undefined by purpose... |
Closes i18next/react-i18next#1559, i18next/react-i18next#1576, i18next/react-i18next#1574
Since
returnNull
option istrue
by default,t
function can returnstring
ornull
. By declaring theresources
type, we can infer the exact return type, so this is only useful to people who can't declare theresource
type .This PR allows to change this ☝️ behaviour if to set the
returnNull
type tofalse
.Checklist
npm run test
Checklist (for documentation change)