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

hooks variant Trans props and useTranslation typings #682

Merged
merged 1 commit into from
Jan 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 36 additions & 30 deletions hooks.d.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import i18next from 'i18next'
import * as React from 'react'
import { Namespace, ReactI18NextOptions, TransProps } from './src/index'
import i18next from 'i18next';
import * as React from 'react';
import { Namespace, ReactI18NextOptions, TransProps } from './src/index';

interface HooksTransProps extends TransProps {
children: React.ReactElement<any>[]
tOptions: {}
ns: Namespace
children: React.ReactElement<any>[];
tOptions?: {};
ns?: Namespace;
}
export function setDefaults(options: ReactI18NextOptions): void
export function getDefaults(): ReactI18NextOptions
export function addUsedNamespaces(namespaces: Namespace[]): void
export function getUsedNamespaces(): string[]
export function setI18n(instance: i18next.i18n): void
export function getI18n(): i18next.i18n
export const initReactI18next: {
type: string
init(instance: i18next.i18n): void
interface UseTranslationOptions {
i18n?: i18next.i18n;
}
export function composeInitialProps(ForComponent: any): (ctx: unknown) => Promise<any>
export function setDefaults(options: ReactI18NextOptions): void;
export function getDefaults(): ReactI18NextOptions;
export function addUsedNamespaces(namespaces: Namespace[]): void;
export function getUsedNamespaces(): string[];
export function setI18n(instance: i18next.i18n): void;
export function getI18n(): i18next.i18n;
export const initReactI18next: {
type: string;
init(instance: i18next.i18n): void;
};
export function composeInitialProps(ForComponent: any): (ctx: unknown) => Promise<any>;
export function getInitialProps(): {
initialI18nStore: {
[ns: string]: {}
}
initialLanguage: string
}
[ns: string]: {};
};
initialLanguage: string;
};
export function Trans({
i18nKey,
count,
Expand All @@ -37,10 +40,13 @@ export function Trans({
tOptions,
ns,
...additionalProps
}: HooksTransProps): any
}: HooksTransProps): any;

export function useSSR(initialI18nStore: any, initialLanguage: any): void
export function useTranslation(ns?: Namespace): [i18next.TranslationFunction, i18next.i18n | {}]
export function useSSR(initialI18nStore: any, initialLanguage: any): void;
export function useTranslation(
ns?: Namespace,
options?: UseTranslationOptions,
): [i18next.TranslationFunction, i18next.i18n | {}];

export function withSSR(): (
WrappedComponent: React.ComponentClass<{}, any>,
Expand All @@ -51,13 +57,13 @@ export function withSSR(): (
initialLanguage,
...rest
}: {
[x: string]: any
initialI18nStore: any
initialLanguage: any
[x: string]: any;
initialI18nStore: any;
initialLanguage: any;
},
): React.ComponentElement<{}, React.Component<{}, any, any>>
getInitialProps: (ctx: unknown) => Promise<any>
}
): React.ComponentElement<{}, React.Component<{}, any, any>>;
getInitialProps: (ctx: unknown) => Promise<any>;
};
export function withTranslation(
ns?: Namespace,
): (WrappedComponent: React.ComponentClass<any>) => (props: any) => any
): (WrappedComponent: React.ComponentClass<any>) => (props: any) => any;