From dc448d51e8d084d27157e5f925aa46bb372a00cc Mon Sep 17 00:00:00 2001 From: Daniel Sogl Date: Thu, 7 Feb 2019 13:27:14 +0100 Subject: [PATCH 1/4] Add missing I18nextProvider interface to typings --- src/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/index.d.ts b/src/index.d.ts index 13be2aead..622d3c553 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -72,6 +72,16 @@ export function withTranslation( component: React.ComponentType

, ) => React.ComponentType>; +export interface I18nextProviderProps { + i18n: i18next.i18n; + defaultNS?: string; + reportNS?: (ns: string) => void; + initialI18nStore?: {}; + initialLanguage?: string; +} + +export const I18nextProvider: React.ComponentClass; + export interface TranslationProps { children: ( t: i18next.TFunction, From 53ecc8e3b1c3cec735f2517b31b6021b14278ba5 Mon Sep 17 00:00:00 2001 From: Daniel Sogl Date: Thu, 7 Feb 2019 14:12:18 +0100 Subject: [PATCH 2/4] remove old props --- src/index.d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 622d3c553..e3d4da71d 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -74,10 +74,6 @@ export function withTranslation( export interface I18nextProviderProps { i18n: i18next.i18n; - defaultNS?: string; - reportNS?: (ns: string) => void; - initialI18nStore?: {}; - initialLanguage?: string; } export const I18nextProvider: React.ComponentClass; From 19fdfd49ee3c1e51cb9742c564e0fca747f79c77 Mon Sep 17 00:00:00 2001 From: Daniel Sogl Date: Thu, 7 Feb 2019 14:38:35 +0100 Subject: [PATCH 3/4] change ClassComponent to FunctionComponent --- src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index e3d4da71d..71c77cd14 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -76,7 +76,7 @@ export interface I18nextProviderProps { i18n: i18next.i18n; } -export const I18nextProvider: React.ComponentClass; +export const I18nextProvider: React.FunctionComponent; export interface TranslationProps { children: ( From 860d8d5fe7146479a932bbd75d2f2caf262f32f3 Mon Sep 17 00:00:00 2001 From: Daniel Sogl Date: Thu, 7 Feb 2019 14:49:44 +0100 Subject: [PATCH 4/4] add usage test --- test/typescript/I18nextProvider.test.tsx | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/typescript/I18nextProvider.test.tsx 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

+
+ + ); +}