i18next / i18next-xhr-backend

[deprecated] can be replaced with i18next-http-backend
https://github.com/i18next/i18next-http-backend
MIT License
253 stars 75 forks source link

Incompatible with latest i18next release #320

Closed danielsogl closed 5 years ago

danielsogl commented 5 years ago

I updates my i18next des to their latest releases and received following error


Failed to compile.

/Users/danielsogl/workspace/vda-rga/react-vdarga/src/i18n/index.ts
TypeScript error in /Users/danielsogl/workspace/vda-rga/react-vdarga/src/i18n/index.ts(35,14):
Argument of type 'typeof I18NextXhrBackend' is not assignable to parameter of type 'Module | ThirdPartyModule[]'.
  Type 'typeof I18NextXhrBackend' is missing the following properties from type 'ThirdPartyModule[]': pop, push, concat, join, and 27 more.  TS2345

    33 | export const initI18n = (env: Environment) => {
    34 |   if (env.translationsEndpoint) {
  > 35 |     i18n.use(XHR).init(
       |              ^
    36 |       Object.assign(i18nOptions, {
    37 |         backend: {
    38 |           loadPath: `${env.translationsEndpoint}?controller=translation&method=getJson&language={{lng}}`,
``
jamuhl commented 5 years ago

PR welcome

Kamahl19 commented 5 years ago

I mentioned the issue also here https://github.com/i18next/i18next-xhr-backend/pull/319#issuecomment-517946389

jamuhl commented 5 years ago

Thank you for mentioning...but I guess all are aware of the problem ... and mentioning it won't fix it magically...

rosskevin commented 5 years ago

Myself and others that worked on the types made the mistake of thinking that the signature was use(instance), not use(classOrObject) in the upstream types (which it is).

I'm adding a test here which confirms the breakage and will figure out the upstream type change in #322

If you are not already aware, you can temporarily workaround this issue with .use(XHR as any).

rosskevin commented 5 years ago

Fix is merged to i18next. Once released, everyone should be good. I'm sorry I mixed this up, it was my misunderstanding of the runtime when tightening the types of the arguments.

Tests added here in #322 to make sure local types are conforming in the future.

jamuhl commented 5 years ago

i18next-xhr-backend@3.1.1 i18next@17.0.9