Improve typings, to avoid "Critical dependency: the request of a dependency is an expression" error with builders
Closed this issue ยท 1 comments
jy95 commented
๐ Feature Proposal
Currently, typings are defined like that :
import { BackendModule, Resource, ReadCallback, ResourceKey } from 'i18next'
type ImportFn = ((language: string, namespace: string, callback: ReadCallback) => void) | ((language: string, namespace: string) => Promise<ResourceKey | boolean | null | undefined>)
declare function resourcesToBackend(res: Resource | ImportFn): BackendModule
export default resourcesToBackend
Would be nice if we can specify enum instead of string for ImportFn, like that :
import { BackendModule, Resource, ReadCallback, ResourceKey } from 'i18next'
type ImportFn<L, N> = ((language: L, namespace: N, callback: ReadCallback) => void) | ((language: L, namespace: N) => Promise<ResourceKey | boolean | null | undefined>)
declare function resourcesToBackend<L = string, N = string>(res: Resource | ImportFn<L, N>): BackendModule
export default resourcesToBackend
Motivation
Example
import resourcesToBackend from "i18next-resources-to-backend";
// ...
resourcesToBackend<"en" | "fr", "common">( /* TODO my import function here */ )
Edit : will create a PR #12 for this ;)
adrai commented
addressed with v1.2.1