Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match the typescript definition with that of the latest version of i18next #631

Merged
merged 1 commit into from Dec 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 13 additions & 17 deletions index.d.ts
@@ -1,22 +1,18 @@
import * as React from 'react';
import {
i18n,
TranslationFunction,
ReactOptions as I18nOptions,
} from 'i18next';
import i18next from 'i18next';
import { Context as ReactContext } from 'create-react-context';

type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type Subtract<T, K> = Omit<T, keyof K>;

export interface ReactI18NextOptions extends I18nOptions {
export interface ReactI18NextOptions extends i18next.ReactOptions {
usePureComponent?: boolean;
omitBoundRerender?: boolean;
}

interface ReactI18nextModule {
type: string;
init: (instance: i18n) => void;
init: (instance: i18next.i18n) => void;
}

export const reactI18nextModule: ReactI18nextModule;
Expand All @@ -25,13 +21,13 @@ export function setDefaults(options: ReactI18NextOptions): void;

export function getDefaults(): ReactI18NextOptions;

export function setI18n(instance: i18n): void;
export function setI18n(instance: i18next.i18n): void;

export function getI18n(): i18n;
export function getI18n(): i18next.i18n;

export interface I18nContextValues {
i18n: i18n;
t: TranslationFunction;
i18n: i18next.i18n;
t: i18next.TranslationFunction;
defaultNS?: string;
reportNS?: string;
lng?: string;
Expand All @@ -55,7 +51,7 @@ export interface WithNamespaces extends WithI18n {

export interface WithNamespacesOptions extends ReactI18NextOptions {
wait: boolean;
i18n?: i18n;
i18n?: i18next.i18n;
innerRef?:
| ((instance: any) => void)
| React.RefObject<HTMLElement | SVGElement | React.Component>;
Expand All @@ -80,9 +76,9 @@ export interface NamespacesConsumerProps extends ReactI18NextOptions {
initialI18nStore?: {};
initialLanguage?: string;
children(
t: TranslationFunction,
t: i18next.TranslationFunction,
options: {
i18n: i18n;
i18n: i18next.i18n;
lng: string;
ready: boolean;
},
Expand All @@ -92,7 +88,7 @@ export interface NamespacesConsumerProps extends ReactI18NextOptions {
export const NamespacesConsumer: React.ComponentClass<NamespacesConsumerProps>;

export interface I18nextProviderProps {
i18n: i18n;
i18n: i18next.i18n;
defaultNS?: string;
initialI18nStore?: {};
initialLanguage?: string;
Expand All @@ -104,8 +100,8 @@ export interface TransProps {
i18nKey?: string;
count?: number;
parent?: React.ReactNode;
i18n?: i18n;
t?: TranslationFunction;
i18n?: i18next.i18n;
t?: i18next.TranslationFunction;
defaults?: string;
values?: {};
components?: React.ReactNode[];
Expand Down