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 to return false when a nullable argument is passed #1635
change to return false when a nullable argument is passed #1635
Conversation
wouldn't it be cleaner to add a check in the exists function itself than in the reused resolve? Like it's already done for the translate here: https://github.com/i18next/i18next/blob/master/src/Translator.js#L87 |
I like your opinion, because |
resolve is internal...currently translate, exist are "public" functions - as translate handles the return value for nullish already it seems logical for me to let exists handle it itself too |
@jamuhl |
9218662
to
f57c097
Compare
@jamuhl |
@jamuhl |
lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Guess this could be released with next version...? |
I have used i18next, react-i18next.
However, when using the i18n object to determine the existence of the key, I found that passing one
nullish factor(undefined or null, or '')
results in the error below:I think
i18n.exist(undefined or null, or '')
should returnfalse
.Similar to mine, there will be many cases that deliver nullish factors, and I think it is obvious that nullish factors do not exist as keys in the resource.
Checklist
npm run test
Checklist (for documentation change)