React-i18next: Backward compatibility issue

Created on 30 Sep 2019  路  7Comments  路  Source: i18next/react-i18next

Describe the bug
I am using react i18next with typescript

I am using useTranslation to get current language

    const { t, i18n } = useTranslation();
...

  const language = i18n.language

I have upgraded my project and then I have a compilation issue on i18n.language

Occurs in react-i18next version
Occurs with #945 - works properly with version 10.12.2

Is there any workaround ?

Thanks !

All 7 comments

@mlecoq I have proven this to be working in #956.

Since you did not provide the ts error you are receiving, and no other details of your setup, I have to assume that this is a local problem.

the ts error is :

Property 'language' does not exist on type 'i18n'.ts(2339)

I only have access to property reportNamespaces

When I look to type definition,

declare module 'i18next' {
  interface i18n {
    reportNamespaces: ReportNamespaces;
  }
}

^^^ declare module code is a typescript augmentation of the existing definition from i18next.

Perhaps your dependencies are out of date, or you are configuring tsconfig in a problematic way.

https://github.com/i18next/react-i18next/pull/956/files proves this works, otherwise the tests would not pass.

Yes you're right, i18next was in version 15.1.3

I have upgraded it to 17.0.4 and It works properly

Sorry !

I am using Create React App so I have not configured manually tsconfig

Maybe an upgrade of peer dependencies is needed ?
"i18next": ">= 17.0.0" instead of "i18next": ">= 14.0.1",

Sure, please PR that @mlecoq and tag me, thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Flo-Slv picture Flo-Slv  路  4Comments

martinlaregina picture martinlaregina  路  3Comments

ChCosmin picture ChCosmin  路  4Comments

dawsbot picture dawsbot  路  4Comments

ezze picture ezze  路  4Comments