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 signature of translate is incorrect. #71

Open
jarkko opened this issue Dec 3, 2020 · 0 comments
Open

Type signature of translate is incorrect. #71

jarkko opened this issue Dec 3, 2020 · 0 comments

Comments

@jarkko
Copy link

jarkko commented Dec 3, 2020

The translate function is typed to always return a string, which is incorrect. In the case of a partial path, it will return an object instead, as seen here.

Thus, code that uses and expects that functionality will not even compile in Typescript because of a type mismatch.

Example:

setTranslations({ foo: "bar", baz: { foo: "bar" } })
const baz = t("baz") // returns { foo: "bar" }
Object.assign(baz, fallback: "") // will bomb because of the incorrect type signature of translate
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

No branches or pull requests

1 participant