diff --git a/src/index.d.ts b/src/index.d.ts index 14ab13720..90affcc87 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -102,7 +102,7 @@ export interface I18nextProviderProps { } export const I18nextProvider: React.FunctionComponent; -export const I18nContext: React.Context; +export const I18nContext: React.Context<{ i18n: i18n }>; export interface TranslationProps { children: ( diff --git a/test/typescript/context.test.tsx b/test/typescript/context.test.tsx index 89d2526ec..69a9b1478 100644 --- a/test/typescript/context.test.tsx +++ b/test/typescript/context.test.tsx @@ -1,4 +1,10 @@ +import { useContext } from 'react'; import i18next from 'i18next'; +import { I18nContext } from 'react-i18next'; i18next.reportNamespaces.addUsedNamespaces(['translation']); i18next.reportNamespaces.getUsedNamespaces(); + +function ContextConsumer() { + const { i18n } = useContext(I18nContext); +}