mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 18:27:56 +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
|
||||
// (Generic permits to handled message provided as React children)
|
||||
type IdOrMessage<MessageKey extends 'children' | 'message'> =
|
||||
| ({[key in MessageKey]: string} & {id?: string})
|
||||
| ({[key in MessageKey]?: string} & {id: string});
|
||||
type IdOrMessage<
|
||||
MessageKey extends 'children' | 'message',
|
||||
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;
|
||||
values?: InterpolateValues<Str, string | number>;
|
||||
};
|
||||
|
||||
export function translate<Str extends string>(
|
||||
|
@ -221,7 +226,10 @@ declare module '@docusaurus/Translate' {
|
|||
values?: InterpolateValues<Str, string | number>,
|
||||
): string;
|
||||
|
||||
export type TranslateProps<Str extends string> = IdOrMessage<'children'> & {
|
||||
export type TranslateProps<Str extends string> = IdOrMessage<
|
||||
'children',
|
||||
Str
|
||||
> & {
|
||||
description?: string;
|
||||
values?: InterpolateValues<Str, ReactNode>;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue