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 errors when using custom contextSeparator #2016

Closed
giovannipiller opened this issue Aug 8, 2023 · 1 comment · Fixed by #2017
Closed

Type errors when using custom contextSeparator #2016

giovannipiller opened this issue Aug 8, 2023 · 1 comment · Fixed by #2017

Comments

@giovannipiller
Copy link

🐛 Bug Report

When contextSeparator has been customized, types will be broken when using a t function providing a context.

The error will be something like this: Type at position 1 in source is not compatible with type at position 1 in target.

Screenshot 2023-08-08 alle 15 38 18

To Reproduce

Your i18n config must have contextSeparator: '|'

// the namespace – custom.json

{
  "example": "Example",
  "example|custom": "Example with context"
}

// the react component

const { t } = useTranslation(['custom']);

// this would result in a type error, `myValue` is `never`
const myValue = t('custom:example', { context: 'custom' });

@marcalexiei will open a PR with a fix and an additional test case.

Expected behavior

There are no type errors when using a custom contextSeparator.
i.e. by adding a way to override the default contextSeparator used by types.

Your Environment

  • runtime version: node v18
  • i18next version: i.e. 23.4.2
  • os: macOS 13.4.1
@adrai
Copy link
Member

adrai commented Aug 8, 2023

Should be addressed by @marcalexiei in v23.4.3.

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

Successfully merging a pull request may close this issue.

2 participants