diff --git a/ts4.1/icu.macro.d.ts b/icu.macro.d.ts similarity index 96% rename from ts4.1/icu.macro.d.ts rename to icu.macro.d.ts index d88d2852..762a66e2 100644 --- a/ts4.1/icu.macro.d.ts +++ b/icu.macro.d.ts @@ -1,6 +1,6 @@ import React from 'react'; -import { Namespace, DefaultNamespace, TFuncKey, Trans } from '.'; -import { i18n } from 'i18next'; +import { Trans } from './'; +import { Namespace, DefaultNamespace, TFuncKey, i18n } from 'i18next'; export { Trans }; diff --git a/index.d.ts b/index.d.ts index 6b833b23..a2c5d1c2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,11 +1,18 @@ -import i18next, { ReactOptions, i18n, ThirdPartyModule, WithT, TFunction, Resource } from 'i18next'; +import i18next, { + ReactOptions, + i18n, + ThirdPartyModule, + Resource, + TFuncKey, + Namespace, + TypeOptions, + TFunction, + KeyPrefix, +} from 'i18next'; import * as React from 'react'; -type Omit = Pick>; type Subtract = Omit; -export type Namespace = string | string[]; - export function setDefaults(options: ReactOptions): void; export function getDefaults(): ReactOptions; export function setI18n(instance: i18n): void; @@ -20,7 +27,7 @@ export function getInitialProps(): { }; export interface ReportNamespaces { - addUsedNamespaces(namespaces: Namespace[]): void; + addUsedNamespaces(namespaces: Namespace): void; getUsedNamespaces(): string[]; } @@ -30,44 +37,76 @@ declare module 'i18next' { } } -export interface TransProps - extends React.HTMLProps, - Partial { - children?: React.ReactNode; +type ObjectOrNever = TypeOptions['allowObjectInHTMLChildren'] extends true + ? Record + : never; +type ReactI18NextChild = React.ReactNode | ObjectOrNever; + +declare module 'react' { + interface HTMLAttributes { + children?: ReactI18NextChild | Iterable; + } +} + +type DefaultNamespace = TypeOptions['defaultNS']; + +type TransChild = React.ReactNode | Record; +export type TransProps< + K extends TFuncKey extends infer A ? A : never, + N extends Namespace = DefaultNamespace, + TKPrefix = undefined, + E = React.HTMLProps +> = E & { + children?: TransChild | TransChild[]; components?: readonly React.ReactElement[] | { readonly [tagName: string]: React.ReactElement }; count?: number; context?: string; defaults?: string; i18n?: i18n; - i18nKey?: string; - ns?: Namespace; + i18nKey?: K | K[]; + ns?: N; parent?: string | React.ComponentType | null; // used in React.createElement if not null tOptions?: {}; values?: {}; shouldUnescape?: boolean; - t?: TFunction; -} -export function Trans(props: TransProps): React.ReactElement; + t?: TFunction; +}; + +export function Trans< + K extends TFuncKey extends infer A ? A : never, + N extends Namespace = DefaultNamespace, + TKPrefix extends KeyPrefix = undefined, + E = React.HTMLProps +>(props: TransProps): React.ReactElement; export function useSSR(initialI18nStore: Resource, initialLanguage: string): void; -export interface UseTranslationOptions { +export interface UseTranslationOptions { i18n?: i18n; useSuspense?: boolean; - keyPrefix?: string; + keyPrefix?: TKPrefix; bindI18n?: string | false; nsMode?: 'fallback' | 'default'; // other of these options might also work: https://github.com/i18next/i18next/blob/master/index.d.ts#L127 } -export type UseTranslationResponse = [TFunction, i18n, boolean] & { - t: TFunction; + +export type UseTranslationResponse = [ + TFunction, + i18n, + boolean, +] & { + t: TFunction; i18n: i18n; ready: boolean; }; -export function useTranslation( - ns?: Namespace, - options?: UseTranslationOptions, -): UseTranslationResponse; + +export function useTranslation< + N extends Namespace = DefaultNamespace, + TKPrefix extends KeyPrefix = undefined +>( + ns?: N | Readonly, + options?: UseTranslationOptions, +): UseTranslationResponse; // Need to see usage to improve this export function withSSR(): ( @@ -84,7 +123,11 @@ export function withSSR(): ( getInitialProps: (ctx: unknown) => Promise; }; -export interface WithTranslation extends WithT { +export interface WithTranslation< + N extends Namespace = DefaultNamespace, + TKPrefix extends KeyPrefix = undefined +> { + t: TFunction; i18n: i18n; tReady: boolean; } @@ -94,20 +137,24 @@ export interface WithTranslationProps { useSuspense?: boolean; } -export function withTranslation( - ns?: Namespace, +export function withTranslation< + N extends Namespace = DefaultNamespace, + TKPrefix extends KeyPrefix = undefined +>( + ns?: N, options?: { withRef?: boolean; + keyPrefix?: TKPrefix; }, ): < - C extends React.ComponentType & WithTranslationProps>, + C extends React.ComponentType & WithTranslationProps>, ResolvedProps = JSX.LibraryManagedAttributes< C, Subtract, WithTranslationProps> > >( component: C, -) => React.ComponentType & WithTranslationProps>; +) => React.ComponentType> & WithTranslationProps>; export interface I18nextProviderProps { children?: React.ReactNode; @@ -118,19 +165,26 @@ export interface I18nextProviderProps { export const I18nextProvider: React.FunctionComponent; export const I18nContext: React.Context<{ i18n: i18n }>; -export interface TranslationProps { +export interface TranslationProps< + N extends Namespace = DefaultNamespace, + TKPrefix extends KeyPrefix = undefined +> { children: ( - t: TFunction, + t: TFunction, options: { i18n: i18n; lng: string; }, ready: boolean, ) => React.ReactNode; - ns?: Namespace; + ns?: N; i18n?: i18n; useSuspense?: boolean; + keyPrefix?: TKPrefix; nsMode?: 'fallback' | 'default'; } -export function Translation(props: TranslationProps): any; +export function Translation< + N extends Namespace = DefaultNamespace, + TKPrefix extends KeyPrefix = undefined +>(props: TranslationProps): any; diff --git a/package-lock.json b/package-lock.json index 15036a74..8fae1780 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,7 @@ "eslint-plugin-react": "^7.16.0", "eslint-plugin-testing-library": "^3.10.1", "husky": "^3.0.3", - "i18next": "^21.0.0", + "i18next": "^22.0.1", "jest": "^24.8.0", "jest-cli": "^24.8.4", "lint-staged": "^8.1.3", @@ -1814,9 +1814,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.5.tgz", - "integrity": "sha512-121rumjddw9c3NCQ55KGkyE1h/nzWhU/owjhw0l4mQrkzz4x9SGS1X8gFLraHwX7td3Yo4QTL+qj0NcIzN87BA==", + "version": "7.19.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.4.tgz", + "integrity": "sha512-EXpLCrk55f+cYqmHsSR+yD/0gAIMxxA9QK9lnQWzhMCvt+YmoBN7Zx94s++Kv0+unHk39vxNO8t+CMA2WSS3wA==", "dependencies": { "regenerator-runtime": "^0.13.4" }, @@ -8100,12 +8100,26 @@ } }, "node_modules/i18next": { - "version": "21.0.0", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-21.0.0.tgz", - "integrity": "sha512-17A00z5ASuOJkPUNSUMaZcfL3zOm2qYiN8UBIYhNYNmPbPrcP+IfabGEFEICv8CCStr/cbjF0Jk/IXNX9hj3ZA==", + "version": "22.0.1", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.0.1.tgz", + "integrity": "sha512-CRbtl6urEcIDbIzP4sGoPf9YuDNto1JgCRsfdvcVUOPb8nPAQ0azhPZiSdD5AFg/Erb58+/nDRmhm8bzVyjABQ==", "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://locize.com" + }, + { + "type": "individual", + "url": "https://locize.com/i18next.html" + }, + { + "type": "individual", + "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + } + ], "dependencies": { - "@babel/runtime": "^7.12.0" + "@babel/runtime": "^7.17.2" } }, "node_modules/iconv-lite": { @@ -16529,9 +16543,9 @@ } }, "@babel/runtime": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.5.tgz", - "integrity": "sha512-121rumjddw9c3NCQ55KGkyE1h/nzWhU/owjhw0l4mQrkzz4x9SGS1X8gFLraHwX7td3Yo4QTL+qj0NcIzN87BA==", + "version": "7.19.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.4.tgz", + "integrity": "sha512-EXpLCrk55f+cYqmHsSR+yD/0gAIMxxA9QK9lnQWzhMCvt+YmoBN7Zx94s++Kv0+unHk39vxNO8t+CMA2WSS3wA==", "requires": { "regenerator-runtime": "^0.13.4" } @@ -21502,12 +21516,12 @@ } }, "i18next": { - "version": "21.0.0", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-21.0.0.tgz", - "integrity": "sha512-17A00z5ASuOJkPUNSUMaZcfL3zOm2qYiN8UBIYhNYNmPbPrcP+IfabGEFEICv8CCStr/cbjF0Jk/IXNX9hj3ZA==", + "version": "22.0.1", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.0.1.tgz", + "integrity": "sha512-CRbtl6urEcIDbIzP4sGoPf9YuDNto1JgCRsfdvcVUOPb8nPAQ0azhPZiSdD5AFg/Erb58+/nDRmhm8bzVyjABQ==", "dev": true, "requires": { - "@babel/runtime": "^7.12.0" + "@babel/runtime": "^7.17.2" } }, "iconv-lite": { diff --git a/package.json b/package.json index 512c0f01..f4281fb7 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,6 @@ "description": "Internationalization for react done right. Using the i18next i18n ecosystem.", "main": "dist/commonjs/index.js", "types": "./index.d.ts", - "typesVersions": { - ">=4.1": { - "*": [ - "ts4.1/*" - ] - } - }, "jsnext:main": "dist/es/index.js", "module": "dist/es/index.js", "keywords": [ @@ -67,7 +60,7 @@ "eslint-plugin-react": "^7.16.0", "eslint-plugin-testing-library": "^3.10.1", "husky": "^3.0.3", - "i18next": "^21.0.0", + "i18next": "^22.0.1", "jest": "^24.8.0", "jest-cli": "^24.8.4", "lint-staged": "^8.1.3", diff --git a/test/typescript/custom-types/custom-types.d.ts b/test/typescript/custom-types/custom-types.d.ts index b2fe112f..1a5b3914 100644 --- a/test/typescript/custom-types/custom-types.d.ts +++ b/test/typescript/custom-types/custom-types.d.ts @@ -1,6 +1,6 @@ -import 'react-i18next'; +import 'i18next'; -declare module 'react-i18next' { +declare module 'i18next' { interface CustomTypeOptions { defaultNS: 'custom'; resources: { diff --git a/test/typescript/returnTypes.test.ts b/test/typescript/returnTypes.test.ts deleted file mode 100644 index 40a6e5c6..00000000 --- a/test/typescript/returnTypes.test.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { KeysWithSeparator, NormalizeByTypeOptions, NormalizeReturn } from 'react-i18next'; - -// Test cases for TypeOptions['returnNull']: true -type ReturnNull = NormalizeByTypeOptions; // Returns null - -const nullableValue: ReturnNull = null; - -// @ts-expect-error: null is not assignable to string -const nonNullableValue: ReturnNull = ''; - -// Test cases for TypeOptions['returnNull']: false -type ReturnNonNullable = NormalizeByTypeOptions; // Returns string - -// @ts-expect-error: null is not assignable to string -const nullableValue2: ReturnNonNullable = null; - -const nonNullableValue2: ReturnNonNullable = ''; - -// Test cases for TypeOptions['returnEmptyString']: false -type ReturnNonEmptyString = NormalizeByTypeOptions<'', { returnEmptyString: false }>; // Returns string - -const emptyStringValue: ReturnNonEmptyString = ''; - -// Emtpy string should always be assignable to string, but not viceversa -const nonEmptyStringValue: ReturnNonEmptyString = 'non-empty-string'; - -// Test cases for TypeOptions['returnEmptyString']: true -type ReturnEmptyString = NormalizeByTypeOptions<'', { returnEmptyString: true }>; // Returns "" - -const emptyStringValue2: ReturnEmptyString = ''; - -// @ts-expect-error: '"non-empty-string"' is not assignable to type '""' -const nonEmptyStringValue2: ReturnEmptyString = 'non-empty-string'; - -// Test cases for TypeOptions['keySeparator']: '.' (default) -type DefaultCase = KeysWithSeparator<'namespace', 'key' | 'key2'>; -const defaultCaseExpectedResult = 'namespace.key'; -const defaultCaseExpectedResult2 = 'namespace.key2'; -const defaultCase: DefaultCase = defaultCaseExpectedResult; -const defaultCase2: DefaultCase = defaultCaseExpectedResult2; - -// Test cases for TypeOptions['keySeparator']: '>>>' (arbitrary separator) -type ArbitrarySeparatorCase = KeysWithSeparator<'namespace', 'key' | 'key2', '>>>'>; -const arbitrarySeparatorExpectedResult = 'namespace>>>key'; -const arbitrarySeparatorExpectedResult2 = 'namespace>>>key2'; -const arbitrarySeparatorCase: ArbitrarySeparatorCase = arbitrarySeparatorExpectedResult; -const arbitrarySeparatorCase2: ArbitrarySeparatorCase = arbitrarySeparatorExpectedResult2; - -// Test cases for TypeOptions['keySeparator']: false (nesting not supported) -interface MockDictionary { - key: { nested: 'value' }; - notNested: 'value'; -} - -type ReturnGivenKey = NormalizeReturn; -const shouldBeGivenKey: ReturnGivenKey = 'key.nested'; - -type ReturnGivenKey2 = NormalizeReturn; -const shouldBeGivenKey2: ReturnGivenKey2 = 'keyfalsenested'; - -type ReturnValue = NormalizeReturn; -const shouldBeTranslationValue: ReturnValue = 'value'; - -type ReturnValue2 = NormalizeReturn; -const shouldBeTranslationValue2: ReturnValue2 = 'value'; diff --git a/ts4.1/index.d.ts b/ts4.1/index.d.ts deleted file mode 100644 index 429e2fe7..00000000 --- a/ts4.1/index.d.ts +++ /dev/null @@ -1,398 +0,0 @@ -import i18next, { - ReactOptions, - i18n, - ThirdPartyModule, - Resource, - TOptions, - StringMap, - TFunctionResult, -} from 'i18next'; -import * as React from 'react'; - -type Subtract = Omit; - -/** - * Due to a limitation/bug on typescript 4.1 (https://github.com/microsoft/TypeScript/issues/41406), we added - * "extends infer A ? A : never" in a few places to suppress the error "Type instantiation is excessively deep and possibly infinite." - * on cases where users have more than 22 namespaces. Once the issue is fixed, we can remove all instances of the workaround used. - * - * Reference of the bug reported: https://github.com/i18next/react-i18next/issues/1222 - */ - -/** - * This interface can be augmented by users to add types to `react-i18next` default resources. - * - * @deprecated use the `resources` key of `CustomTypeOptions` instead - */ -export interface Resources {} -/** - * This interface can be augmented by users to add types to `react-i18next`. It accepts a `defaultNS`, `resources`, `returnNull` and `returnEmptyString` properties. - * - * Usage: - * ```ts - * // react-i18next.d.ts - * import 'react-i18next'; - * declare module 'react-i18next' { - * interface CustomTypeOptions { - * defaultNS: 'custom'; - * returnNull: false; - * returnEmptyString: false; - * nsSeparator: ':'; - * keySeparator: '.'; - * jsonFormat: 'v4'; - * allowObjectInHTMLChildren: false; - * resources: { - * custom: { - * foo: 'foo'; - * }; - * }; - * } - * } - * ``` - */ -export interface CustomTypeOptions {} - -type MergeBy = Omit & K; - -type TypeOptions = MergeBy< - { - returnNull: true; - returnEmptyString: true; - keySeparator: '.'; - nsSeparator: ':'; - defaultNS: 'translation'; - jsonFormat: 'v4'; - resources: Resources; - allowObjectInHTMLChildren: false; - }, - CustomTypeOptions ->; - -type DefaultResources = TypeOptions['resources']; -type DefaultNamespace = T extends Fallback ? T : string; - -type Fallback = [T] extends [never] ? F : T; - -export type Namespace> = F | F[]; - -export function setDefaults(options: ReactOptions): void; -export function getDefaults(): ReactOptions; -export function setI18n(instance: i18n): void; -export function getI18n(): i18n; -export const initReactI18next: ThirdPartyModule; -export function composeInitialProps(ForComponent: any): (ctx: unknown) => Promise; -export function getInitialProps(): { - initialI18nStore: { - [ns: string]: {}; - }; - initialLanguage: string; -}; - -export interface ReportNamespaces { - addUsedNamespaces(namespaces: Namespace[]): void; - getUsedNamespaces(): string[]; -} - -declare module 'i18next' { - interface i18n { - reportNamespaces: ReportNamespaces; - } -} - -type ObjectOrNever = TypeOptions['allowObjectInHTMLChildren'] extends true - ? Record - : never; - -type ReactI18NextChild = React.ReactNode | ObjectOrNever; - -declare module 'react' { - interface HTMLAttributes { - children?: ReactI18NextChild | Iterable; - } -} - -type PluralSuffix = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other'; - -type WithOrWithoutPlural = TypeOptions['jsonFormat'] extends 'v4' - ? K extends `${infer B}_${PluralSuffix}` - ? B | K - : K - : K; - -// Normalize single namespace -export type KeysWithSeparator = `${K1 & - string}${S}${K2 & string}`; -type KeysWithSeparator2 = KeysWithSeparator>; -type Normalize2 = K extends keyof T - ? T[K] extends Record - ? T[K] extends readonly any[] - ? - | KeysWithSeparator2> - | KeysWithSeparator2> - : - | KeysWithSeparator> - | KeysWithSeparator> - : never - : never; -type Normalize = WithOrWithoutPlural | Normalize2; - -// Normalize multiple namespaces -type KeyWithNSSeparator = `${N & - string}${S}${K & string}`; -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void - ? I - : never; -type LastOf = UnionToIntersection T : never> extends () => infer R - ? R - : never; -type NormalizeMulti> = L extends U - ? KeyWithNSSeparator> | NormalizeMulti> - : never; - -interface CustomTypeParameters { - returnNull?: boolean; - returnEmptyString?: boolean; -} - -type TypeOptionsFallback = Option extends false - ? TranslationValue extends MatchingValue - ? string - : TranslationValue - : TranslationValue; - -/** - * Checks if user has enabled `returnEmptyString` and `returnNull` options to retrieve correct values. - */ -export type NormalizeByTypeOptions< - TranslationValue, - Options extends CustomTypeParameters = TypeOptions, - R = TypeOptionsFallback -> = TypeOptionsFallback; - -type StringIfPlural = TypeOptions['jsonFormat'] extends 'v4' - ? T extends `${string}_${PluralSuffix}` - ? string - : never - : never; - -type NormalizeReturn< - T, - V, - S extends string | false = TypeOptions['keySeparator'] -> = V extends keyof T - ? NormalizeByTypeOptions - : S extends false - ? V - : V extends `${infer K}${S}${infer R}` - ? K extends keyof T - ? NormalizeReturn - : never - : StringIfPlural; - -type NormalizeMultiReturn = V extends `${infer N}:${infer R}` - ? N extends keyof T - ? NormalizeReturn - : never - : never; - -type NormalizeWithKeyPrefix< - T, - K, - S extends string = TypeOptions['keySeparator'] -> = K extends `${infer K1}${S}${infer K2}` - ? K1 extends keyof T - ? NormalizeWithKeyPrefix - : never - : K extends keyof T - ? T[K] extends string - ? never - : Normalize - : never; - -type KeyPrefix = - | (N extends keyof DefaultResources ? Normalize : string) - | undefined; - -export type TFuncKey< - N extends Namespace = DefaultNamespace, - TKPrefix = undefined, - T = DefaultResources -> = N extends (keyof T)[] | Readonly<(keyof T)[]> - ? NormalizeMulti - : N extends keyof T - ? TKPrefix extends undefined - ? Normalize - : NormalizeWithKeyPrefix - : string; - -export type TFuncReturn< - N, - TKeys, - TDefaultResult, - TKPrefix = undefined, - T = DefaultResources -> = N extends (keyof T)[] - ? NormalizeMultiReturn - : N extends keyof T - ? TKPrefix extends undefined - ? NormalizeReturn - : NormalizeReturn> - : Fallback; - -export interface TFunction { - < - TKeys extends TFuncKey | TemplateStringsArray extends infer A ? A : never, - TDefaultResult extends TFunctionResult | React.ReactNode = string, - TInterpolationMap extends object = StringMap - >( - key: TKeys | TKeys[], - options?: TOptions | string, - ): TFuncReturn; - < - TKeys extends TFuncKey | TemplateStringsArray extends infer A ? A : never, - TDefaultResult extends TFunctionResult | React.ReactNode = string, - TInterpolationMap extends object = StringMap - >( - key: TKeys | TKeys[], - defaultValue?: string, - options?: TOptions | string, - ): TFuncReturn; -} - -type TransChild = React.ReactNode | Record; -export type TransProps< - K extends TFuncKey extends infer A ? A : never, - N extends Namespace = DefaultNamespace, - TKPrefix = undefined, - E = React.HTMLProps -> = E & { - children?: TransChild | TransChild[]; - components?: readonly React.ReactElement[] | { readonly [tagName: string]: React.ReactElement }; - count?: number; - context?: string; - defaults?: string; - i18n?: i18n; - i18nKey?: K | K[]; - ns?: N; - parent?: string | React.ComponentType | null; // used in React.createElement if not null - tOptions?: {}; - values?: {}; - shouldUnescape?: boolean; - t?: TFunction; -}; - -export function Trans< - K extends TFuncKey extends infer A ? A : never, - N extends Namespace = DefaultNamespace, - TKPrefix extends KeyPrefix = undefined, - E = React.HTMLProps ->(props: TransProps): React.ReactElement; - -export function useSSR(initialI18nStore: Resource, initialLanguage: string): void; - -export interface UseTranslationOptions { - i18n?: i18n; - useSuspense?: boolean; - keyPrefix?: TKPrefix; - bindI18n?: string | false; - nsMode?: 'fallback' | 'default'; -} - -export type UseTranslationResponse = [ - TFunction, - i18n, - boolean, -] & { - t: TFunction; - i18n: i18n; - ready: boolean; -}; - -export function useTranslation< - N extends Namespace = DefaultNamespace, - TKPrefix extends KeyPrefix = undefined ->( - ns?: N | Readonly, - options?: UseTranslationOptions, -): UseTranslationResponse; - -// Need to see usage to improve this -export function withSSR(): ( - WrappedComponent: React.ComponentType, -) => { - ({ - initialI18nStore, - initialLanguage, - ...rest - }: { - initialI18nStore: Resource; - initialLanguage: string; - } & Props): React.FunctionComponentElement; - getInitialProps: (ctx: unknown) => Promise; -}; - -export interface WithTranslation< - N extends Namespace = DefaultNamespace, - TKPrefix extends KeyPrefix = undefined -> { - t: TFunction; - i18n: i18n; - tReady: boolean; -} - -export interface WithTranslationProps { - i18n?: i18n; - useSuspense?: boolean; -} - -export function withTranslation< - N extends Namespace = DefaultNamespace, - TKPrefix extends KeyPrefix = undefined ->( - ns?: N, - options?: { - withRef?: boolean; - keyPrefix?: TKPrefix; - }, -): < - C extends React.ComponentType & WithTranslationProps>, - ResolvedProps = JSX.LibraryManagedAttributes< - C, - Subtract, WithTranslationProps> - > ->( - component: C, -) => React.ComponentType> & WithTranslationProps>; - -export interface I18nextProviderProps { - children?: React.ReactNode; - i18n: i18n; - defaultNS?: string; -} - -export const I18nextProvider: React.FunctionComponent; -export const I18nContext: React.Context<{ i18n: i18n }>; - -export interface TranslationProps< - N extends Namespace = DefaultNamespace, - TKPrefix extends KeyPrefix = undefined -> { - children: ( - t: TFunction, - options: { - i18n: i18n; - lng: string; - }, - ready: boolean, - ) => React.ReactNode; - ns?: N; - i18n?: i18n; - useSuspense?: boolean; - keyPrefix?: TKPrefix; - nsMode?: 'fallback' | 'default'; -} - -export function Translation< - N extends Namespace = DefaultNamespace, - TKPrefix extends KeyPrefix = undefined ->(props: TranslationProps): any;