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

namespacesRequired in serverSideTranslations is not type-safe anymore #2201

Closed
t-ondrej opened this issue Sep 2, 2023 · 3 comments · Fixed by #2203
Closed

namespacesRequired in serverSideTranslations is not type-safe anymore #2201

t-ondrej opened this issue Sep 2, 2023 · 3 comments · Fixed by #2203

Comments

@t-ondrej
Copy link
Contributor

t-ondrej commented Sep 2, 2023

💥 Regression Report

namespacesRequired type in serverSideTranslations is not constrained by the Namespace anymore. Type-safety achieved by overriding CustomTypeOptions in i18next.d.ts is lost and any string is accepted now.

The change was introduced in this commit.

Note: Don't know the typescript error that the commit fixed, but shouldn't the ElementArrayOrSelf have the following type

type ArrayElementOrSelf<T> = 
  T extends Array<infer U> 
    ? U[] 
    : T; // <-- Not T[] because it's not an identity of T

Last working version

Worked up to version: 13.3.0

Stopped working in version: 14.0.0

Expected behavior

serverSideTranslations.namespacesRequired accepts namespaces only. If no namespace is defined, any string is valid.

@adrai
Copy link
Member

adrai commented Sep 2, 2023

Would you like to provide A PR to address this?

@adrai
Copy link
Member

adrai commented Sep 2, 2023

Can you try with v14.0.2 ?

@t-ondrej
Copy link
Contributor Author

t-ondrej commented Sep 4, 2023

Thank you for the quick response. Unfortunately, it still didn't work. I have provided a PR that fixes it.

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.

2 participants