Skip to content
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

PluralProps doesn't include values #1444

Closed
mwalkerr opened this issue Feb 7, 2022 · 5 comments · Fixed by #1446
Closed

PluralProps doesn't include values #1444

mwalkerr opened this issue Feb 7, 2022 · 5 comments · Fixed by #1446
Assignees

Comments

@mwalkerr
Copy link
Contributor

mwalkerr commented Feb 7, 2022

🐛 Bug Report

The PluralProps type as defined in ts4.1/icu.macro.d.ts doesn't include the values prop, which is required if there is a placeholder value inside a pluralized translation

To Reproduce

Without @ts-ignore, TS complains that TS2322: Type 'string' is not assignable to type 'never'.

              <Plural
                i18nKey="pluralizationEmbedded" // optional key
                count={foxPlural}
                // @ts-ignore because values are required..
                values={{ animalColor }}
                $0={
                  <>
                    The nonexistant quick <Text style={textStyles.bold}>{animalColor}</Text> foxes.
                  </>
                }
                one={
                  <>
                    The quick <Text style={textStyles.bold}>{animalColor}</Text> fox.
                  </>
                }
                other={
                  <>
                    The # quick <Text style={textStyles.bold}>{animalColor}</Text> foxes.
                  </>
                }
              />

Expected behavior

No type error

Your Environment

  • runtime version: React Native 0.63.4
  • i18next version: 11.15.3
  • os: Mac
@adrai
Copy link
Member

adrai commented Feb 7, 2022

Would you like to send a Pull Request to address this?

@mwalkerr
Copy link
Contributor Author

mwalkerr commented Feb 7, 2022

@adrai Sure, I can attempt that. Should I use the same type that's used for TransProps of values?: {}? Should it go directly on PluralProps?

@adrai
Copy link
Member

adrai commented Feb 7, 2022

Maybe @pedrodurek can advice?

@pedrodurek
Copy link
Member

pedrodurek commented Feb 7, 2022

As we don't infer other props based on values, it makes sense to me values to be values?: {} or values?: object under PluralSubProps. Feel free to open the PR @mwalkerr. Thanks for that!

@mwalkerr
Copy link
Contributor Author

mwalkerr commented Feb 7, 2022

@adrai @pedrodurek Just opened one here: #1446. Haven't created too many Github PRs, lemme know if I'm missing anything :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants