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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find namespace 'i18next' #1361

Closed
JuhG opened this issue Aug 26, 2021 · 9 comments
Closed

Cannot find namespace 'i18next' #1361

JuhG opened this issue Aug 26, 2021 · 9 comments

Comments

@JuhG
Copy link

JuhG commented Aug 26, 2021

馃悰 Bug Report

Using version 9.0.10 typescript is complaining, that the function t is not typed. We're using the type WithNamespaces, but for some reason it didn't contain the types coming from i18next. Checking the type file, it looks like this:

Screenshot 2021-08-26 at 20 03 06

Cannot find namespace 'i18next' - somehow importing the types is not working.

Changing
import i18next from 'i18next';
to
import * as i18next from 'i18next';
seem to resolve it.

Sorry if this has already come up, but I couldn't find it.

Your Environment

  • runtime version: node 12.22.3
  • i18next version: 20.4.0
  • os: Mac
@adrai
Copy link
Member

adrai commented Aug 26, 2021

WithNamespaces is very old
please update react-i18next

https://react.i18next.com/latest/migrating-v9-to-v10

@JuhG
Copy link
Author

JuhG commented Aug 26, 2021

We definitely plan to upgrade, but it's an old and big project, so changing all the withNamespaces calls and Interpolate components will take time.
Does the change I proposed have any drawback?
Thanks for the help!

@adrai
Copy link
Member

adrai commented Aug 26, 2021

Does the change I proposed have any drawback?

<= v9 is not supported anymore, so you have only advantages ;-)

@adrai
Copy link
Member

adrai commented Aug 27, 2021

@pedrodurek another reason why I would prefer to split the types...
those for react-i18next in this repo...
etc.

@pedrodurek
Copy link
Member

I was on vacation 馃槄. @adrai I didn't get your question, could you clarify a little bit more?

@adrai
Copy link
Member

adrai commented Aug 31, 2021

Welcome back @pedrodurek 馃槈. Do you remember, some time ago we discussed if there was a possibility to have the types defined each in the appropriate module, so i18next would not need to be updated im case a TypeScript change in the react-i18next interface is done.
I think it was here: i18next/i18next#1626 (comment)

@pedrodurek
Copy link
Member

As answered on the other issue, build-in types are always preferable. I've already faced some issues with external types and type augmentation, where the internal type definitions were being ignored in favour of the external library.

@pedrodurek
Copy link
Member

Hey @JuhG, let me know if the issue was fixed after updating the libraries

@stale
Copy link

stale bot commented Sep 10, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 10, 2021
@stale stale bot closed this as completed Sep 19, 2021
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

4 participants