i18next / i18next-chained-backend

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

TypeScript error triggered between `i18next-chained-backend` and `i18next-http-backend` #22

Closed jdeniau closed 3 years ago

jdeniau commented 3 years ago

🐛 Bug Report

There is a conflict in the .d.ts files between i18next-chained-backend and i18next-http-backend

To Reproduce

i18n config

import i18n from 'i18next';
import ChainedBackend from 'i18next-chained-backend';
import HttpApi from 'i18next-http-backend';

const httpBackend = new HttpApi(null, {
  loadPath: '/somewhere'
});

i18n
  .use(ChainedBackend)
  .init({
    backend: {
      backends: [
        httpBackend,
       // fallback backend
      ],
    },
  });

Current behavior

node_modules/i18next-http-backend/index.d.ts:122:5 - error TS2717: Subsequent property declarations must have the same type.  Property 'backend' must be of type 'BackendOptions | undefined', but here has type 'BackendOptions | undefined'.

122     backend?: BackendOptions;
        ~~~~~~~

  node_modules/i18next-chained-backend/index.d.ts:42:5
    42     backend?: I18NextChainedBackend.BackendOptions;
           ~~~~~~~
    'backend' was also declared here.

Expected behavior

No error

Possible temporary fix

Setting "skipLibCheck": true hide the issue

Your Environment

adrai commented 3 years ago

did you set the skipLibCheck to true? https://github.com/i18next/i18next-chained-backend#typescript

jdeniau commented 3 years ago

@adrai Oh sorry I didn't see that this is in the readme file 🤦

As a matter of fact I did post the solution as a "temporary fix" in my issue.

It is something that is fixable that you did not managed to fix or is it by design ?

adrai commented 3 years ago

@pedrodurek maybe knows the detail?

pedrodurek commented 3 years ago

It's by design, that's the only way to automatically infer PluginOptions which happens to have conflicts with other plugins. skipLibCheck: true is also recommended to reduce compilation time.