Skip to content

Commit

Permalink
Merge pull request #682 from panjiesw/fix/hooks-typings
Browse files Browse the repository at this point in the history
hooks variant Trans props and useTranslation typings
  • Loading branch information
jamuhl authored Jan 19, 2019
2 parents 71fdd5b + 5788ab9 commit 36e6936
Showing 1 changed file with 36 additions and 30 deletions.
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;

0 comments on commit 36e6936

Please sign in to comment.