TS Definitions don't acknowledge other backends or their configuration possibilities
robinlahtinen opened this issue · 1 comments
Describe the bug
For example using i18next-async-backend works fine, but it uses backend.resources instead of backend.loadPath and the backend type differs a little bit.
TS2322: Type '{ resources: { "en-US": { common: () => Promise<{ default: { hello: string; }; hello: string; }>; }; }; }' is not assignable to type 'BackendOptions'. Object literal may only specify known properties, and 'resources' does not exist in type 'BackendOptions'.
TS2322: Type 'typeof AsyncBackend' is not assignable to type 'NewableModule<BackendModule<unknown>>'. Types of property 'type' are incompatible. Type 'string' is not assignable to type '"backend"'. server.d.ts(53, 5): The expected type comes from property 'backend' which is declared here on type 'RemixI18NextOption'
Options for RemixI18Next:
import {RemixI18Next} from "remix-i18next";
import AsyncBackend from "i18next-async-backend";
export const i18n = new RemixI18Next({
detection: {
supportedLanguages: ["en-US"],
fallbackLanguage: "en-US"
},
i18next: {
backend: {
resources: localeResources
}
},
backend: AsyncBackend
});
Your Example Website or App
https://github.com/Widen/i18next-async-backend
Steps to Reproduce the Bug or Issue
- Follow the remix-i18next guide on readme
- Instead of FS backend use i18next-async-backend for server
Expected behavior
TypeScript sees the configuration options as valid.
Screenshots or Videos
No response
Platform
- Windows 10
- Node.js 18
- React 18
- TypeScript 4.6.4
Additional context
No response
The types of the i18next comes from the actual init options type exported by the library, it only omits the React (because on the server class it's not used) and detection (because it's configured in another option).
Line 62 in 58a842a
If the i18next.backend.resources
key is type is not considered valid then it must be an error in the InitOptions or i18next-async-backend is using an invalid option.
And the type of the backend
options also comes from i18next itself, so again the i18next-asnyc-backend is not conforming with the official type.
Line 67 in 58a842a