Skip to content

Commit

Permalink
fix Translation component types (#1509)
Browse files Browse the repository at this point in the history
  • Loading branch information
vovsemenv authored Jun 3, 2022
1 parent cc73dba commit f59657c
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions ts4.1/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,11 @@ export function withSSR(): <Props>(
getInitialProps: (ctx: unknown) => Promise<any>;
};

export interface WithTranslation<N extends Namespace = DefaultNamespace> {
t: TFunction<N>;
export interface WithTranslation<
N extends Namespace = DefaultNamespace,
TKPrefix extends KeyPrefix<N> = undefined
> {
t: TFunction<N, TKPrefix>;
i18n: i18n;
tReady: boolean;
}
Expand All @@ -337,10 +340,14 @@ export interface WithTranslationProps {
useSuspense?: boolean;
}

export function withTranslation<N extends Namespace = DefaultNamespace>(
export function withTranslation<
N extends Namespace = DefaultNamespace,
TKPrefix extends KeyPrefix<N> = undefined
>(
ns?: N,
options?: {
withRef?: boolean;
keyPrefix?: TKPrefix;
},
): <
C extends React.ComponentType<React.ComponentProps<any> & WithTranslationProps>,
Expand All @@ -361,9 +368,9 @@ export interface I18nextProviderProps {
export const I18nextProvider: React.FunctionComponent<I18nextProviderProps>;
export const I18nContext: React.Context<{ i18n: i18n }>;

export interface TranslationProps<N extends Namespace = DefaultNamespace> {
export interface TranslationProps<N extends Namespace = DefaultNamespace, TKPrefix> {
children: (
t: TFunction<N>,
t: TFunction<N, TKPrefix>,
options: {
i18n: i18n;
lng: string;
Expand All @@ -373,8 +380,10 @@ export interface TranslationProps<N extends Namespace = DefaultNamespace> {
ns?: N;
i18n?: i18n;
useSuspense?: boolean;
keyPrefix?: TKPrefix;
}

export function Translation<N extends Namespace = DefaultNamespace>(
props: TranslationProps<N>,
): any;
export function Translation<
N extends Namespace = DefaultNamespace,
TKPrefix extends KeyPrefix<N> = undefined
>(props: TranslationProps<N, TKPrefix>): any;

0 comments on commit f59657c

Please sign in to comment.