From afa361b2b7115f34ee3534488be7af6542a84129 Mon Sep 17 00:00:00 2001 From: Wu Haotian Date: Tue, 7 Aug 2018 03:08:15 +0800 Subject: [PATCH] react-i18next: allow React.ReactNode as I18nextProvider's children and I18n's render function return value (#27895) --- types/react-i18next/index.d.ts | 1 + types/react-i18next/src/I18n.d.ts | 2 +- types/react-i18next/src/I18nextProvider.d.ts | 2 +- types/react-i18next/test/react-i18next-tests.tsx | 8 ++++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/types/react-i18next/index.d.ts b/types/react-i18next/index.d.ts index e7b9c88526..979c648f50 100644 --- a/types/react-i18next/index.d.ts +++ b/types/react-i18next/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Giedrius Grabauskas // Simon Baumann // Benedict Etzel +// Wu Haotian // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 diff --git a/types/react-i18next/src/I18n.d.ts b/types/react-i18next/src/I18n.d.ts index 6bc1cf8f0f..91de868caf 100644 --- a/types/react-i18next/src/I18n.d.ts +++ b/types/react-i18next/src/I18n.d.ts @@ -15,7 +15,7 @@ export interface i18nProps { i18n?: i18n; initialI18nStore?: any; initialLanguage?: string; - children: (t: TranslationFunction, options: Options) => JSX.Element; + children: (t: TranslationFunction, options: Options) => React.ReactNode; } export default class I18n extends React.Component { } diff --git a/types/react-i18next/src/I18nextProvider.d.ts b/types/react-i18next/src/I18nextProvider.d.ts index 2cd4e333e3..2db5d0361b 100644 --- a/types/react-i18next/src/I18nextProvider.d.ts +++ b/types/react-i18next/src/I18nextProvider.d.ts @@ -6,7 +6,7 @@ export interface I18nextProviderProps { i18n: i18n; initialI18nStore?: any; initialLanguage?: string; - children: JSX.Element; + children: React.ReactNode; } export default class I18nextProvider extends React.Component { } diff --git a/types/react-i18next/test/react-i18next-tests.tsx b/types/react-i18next/test/react-i18next-tests.tsx index d3afe7643a..30b95ece24 100644 --- a/types/react-i18next/test/react-i18next-tests.tsx +++ b/types/react-i18next/test/react-i18next-tests.tsx @@ -107,6 +107,10 @@ class App extends React.Component { ; + + 123 +; + loadNamespaces({components: [App], i18n}).then(() => { }).catch(error => { }); @@ -182,6 +186,10 @@ interface CustomTranslateFunctionProps { } ; + + {t => '123'} +; + const defaults: ReactI18NextOptions = { wait: true, withRef: true,