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

Type-definitions for Trans-component do not allow array as i18nKey #1281

Closed
therealtbs opened this issue Mar 18, 2021 · 1 comment
Closed
Assignees

Comments

@therealtbs
Copy link

🐛 Bug Report

The TypeScript definitions for the Trans-component don't allow you to specify an array of i18nKeys.

To Reproduce

codesandbox

This (undocumented, for the Trans-component at least, for the t-function see here) feature already works well with the only problem being the type-definitions.

t(["key1", "fallbackKey"]) // works and gives no TypeScript errors

  <Trans
    i18nKey={["key1", "fallbackKey"]}
//  ^ Type error: Type 'string[]' is not assignable to type 'string'.
  /> // works otherwise

Expected behavior

The type-definitions for the t-function allow this. Since the Trans-component uses the t-function in order to resolve the message, I would expect to be able to supply fallback keys as if I was using the t-function directly.

t(["key1", "fallbackKey"]) // works and gives no TypeScript errors

  <Trans
    i18nKey={["key1", "fallbackKey"]}
  /> // works and gives no TypeScript errors

Your Environment

  • runtime version: Chrome 89, doesn't matter
  • i18next version: i18next@19.9.2, react-i18next@11.8.10
  • os: Windows, Linux
  • typescript version: 4.2.3
@pedrodurek pedrodurek mentioned this issue Mar 20, 2021
4 tasks
@pedrodurek
Copy link
Member

Hey @therealtbs, it should be fixed now!

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

No branches or pull requests

3 participants