mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-01 11:18:24 +02:00
fix(module-type-aliases): fix type def for translate params (#6469)
This commit is contained in:
parent
d0fc31c8ae
commit
f0b08f493d
1 changed files with 14 additions and 6 deletions
|
@ -207,13 +207,18 @@ declare module '@docusaurus/Translate' {
|
||||||
|
|
||||||
// TS type to ensure that at least one of id or message is always provided
|
// TS type to ensure that at least one of id or message is always provided
|
||||||
// (Generic permits to handled message provided as React children)
|
// (Generic permits to handled message provided as React children)
|
||||||
type IdOrMessage<MessageKey extends 'children' | 'message'> =
|
type IdOrMessage<
|
||||||
| ({[key in MessageKey]: string} & {id?: string})
|
MessageKey extends 'children' | 'message',
|
||||||
| ({[key in MessageKey]?: string} & {id: string});
|
Str extends string,
|
||||||
|
> =
|
||||||
|
| ({[key in MessageKey]: Str} & {id?: string})
|
||||||
|
| ({[key in MessageKey]?: Str} & {id: string});
|
||||||
|
|
||||||
export type TranslateParam<Str extends string> = IdOrMessage<'message'> & {
|
export type TranslateParam<Str extends string> = IdOrMessage<
|
||||||
|
'message',
|
||||||
|
Str
|
||||||
|
> & {
|
||||||
description?: string;
|
description?: string;
|
||||||
values?: InterpolateValues<Str, string | number>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function translate<Str extends string>(
|
export function translate<Str extends string>(
|
||||||
|
@ -221,7 +226,10 @@ declare module '@docusaurus/Translate' {
|
||||||
values?: InterpolateValues<Str, string | number>,
|
values?: InterpolateValues<Str, string | number>,
|
||||||
): string;
|
): string;
|
||||||
|
|
||||||
export type TranslateProps<Str extends string> = IdOrMessage<'children'> & {
|
export type TranslateProps<Str extends string> = IdOrMessage<
|
||||||
|
'children',
|
||||||
|
Str
|
||||||
|
> & {
|
||||||
description?: string;
|
description?: string;
|
||||||
values?: InterpolateValues<Str, ReactNode>;
|
values?: InterpolateValues<Str, ReactNode>;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue