i18next / i18next-chained-backend

An i18next backend to chain multiple backends (add fallbacks, caches, ...)
MIT License
66 stars 10 forks source link

Type 'ChainedBackendOptions' has no properties in common with type 'InitOptions<unknown>' #29

Closed laclance closed 1 year ago

laclance commented 1 year ago

After updating packages I cannot get rid of typescipt errors. I copied the example from the docs. If I remove the <ChainedBackendOptions> then it says 'backends' does not exist in type 'LocizeBackendOptions'.

import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import ChainedBackend, { ChainedBackendOptions } from 'i18next-chained-backend';
import LocizeBackend from 'i18next-locize-backend';
import HTTPBackendLocal from 'i18next-http-backend';
import pos from 'pos.json';

export const defaultNS = 'pos';
export const resources = {
  en: {
    pos
  }
} as const;

i18next
  .use(initReactI18next)
  .use(ChainedBackend)
  .init(<ChainedBackendOptions>{
    backend: {
      backends: [
        LocizeBackend, // primary
        HTTPBackendLocal // fallback
      ],
      backendOptions: [
        {
          projectId: 'myLocizeProjectId'
        },
        {
          loadPath: '/locales/{{lng}}/{{ns}}.json' // http api load path for my own fallback
        }
      ]
    },
    fallbackLng: 'en',
    fallbackNS: 'pos',
    defaultNS: 'pos',
    ns: ['pos'],
    interpolation: {
      escapeValue: false
    }
  });

export default i18next;
adrai commented 1 year ago

Make sure you've updated all i18next dependencies. If the problem still persists, create a minimal reproducible repository or similar please.

adrai commented 1 year ago

make sure you've installed v6.1.1 of i18next-locize-backend

adrai commented 1 year ago

seems to work: https://github.com/i18next/i18next-chained-backend/blob/master/test/typescript/basic.test-d.ts

laclance commented 1 year ago

thank you, yarn did not update to v6.1.1