1
0
mirror of https://github.com/flarum/core.git synced 2025-08-08 01:16:52 +02:00

fix: return Mithril.Children in translator outputs

This avoids having `NestedStringArray` in generated dist typings which can make it hard to override content with null.
This commit is contained in:
Alexander Skvortsov
2022-03-21 00:32:56 -04:00
parent c9fdd0753f
commit 222d9ccff7

View File

@@ -1,4 +1,6 @@
declare module '@askvortsov/rich-icu-message-formatter' {
import Mithril from 'mithril';
type IValues = Record<string, any>;
type ITypeHandler = (
@@ -10,16 +12,13 @@ declare module '@askvortsov/rich-icu-message-formatter' {
) => string;
type IRichHandler = (tag: any, values: IValues, contents: string) => any;
type ValueOrArray<T> = T | ValueOrArray<T>[];
type NestedStringArray = ValueOrArray<string>;
export class RichMessageFormatter {
locale: string | null;
constructor(locale: string | null, typeHandlers: Record<string, ITypeHandler>, richHandler: IRichHandler);
format(message: string, values: IValues): string;
process(message: string, values: IValues): NestedStringArray;
rich(message: string, values: IValues): NestedStringArray;
process(message: string, values: IValues): Mithril.Children;
rich(message: string, values: IValues): Mithril.Children;
}
export function mithrilRichHandler(tag: any, values: IValues, contents: string): any;