From 6065af7b5a08ec2579109901d1eb7109100b6ca2 Mon Sep 17 00:00:00 2001 From: Daniel Sogl Date: Thu, 7 Feb 2019 14:53:59 +0100 Subject: [PATCH] Add missing I18nextProvider interface to typings (#721) * Add missing I18nextProvider interface to typings * remove old props * change ClassComponent to FunctionComponent * add usage test --- src/index.d.ts | 6 +++++ test/typescript/I18nextProvider.test.tsx | 31 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/typescript/I18nextProvider.test.tsx diff --git a/src/index.d.ts b/src/index.d.ts index 13be2aead..71c77cd14 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -72,6 +72,12 @@ export function withTranslation( component: React.ComponentType

, ) => React.ComponentType>; +export interface I18nextProviderProps { + i18n: i18next.i18n; +} + +export const I18nextProvider: React.FunctionComponent; + export interface TranslationProps { children: ( t: i18next.TFunction, diff --git a/test/typescript/I18nextProvider.test.tsx b/test/typescript/I18nextProvider.test.tsx new file mode 100644 index 000000000..5249dc913 --- /dev/null +++ b/test/typescript/I18nextProvider.test.tsx @@ -0,0 +1,31 @@ +import i18n from 'i18next'; +import * as React from 'react'; +import { I18nextProvider, initReactI18next } from 'react-i18next'; + +i18n.use(initReactI18next).init({ + fallbackLng: 'en', + + // have a common namespace used around the full app + ns: ['translations'], + defaultNS: 'translations', + + debug: true, + + interpolation: { + escapeValue: false, // not needed for react!! + }, + + react: { + wait: true, + }, +}); + +function test() { + return ( + Loading

}> + +

Foo

+
+ + ); +}