Skip to content

Commit ede7d61

Browse files
sdirixlucas-koehler
authored andcommitted
Improve Translator type
The Translator type is an overloaded function. While the current type considers the 'defaultMessage' to be either 'string' or 'undefined' it does not handle the case where it could be 'string | undefined' while the implementation obviously handles this fine. This change adds this additional case to the 'Translator' type and optionalizes the 'defaultMessage' parameter. This allows a more convenient use of this type by adopters.
1 parent 0334763 commit ede7d61

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/core/src/i18n/i18nTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { JsonSchema, UISchemaElement } from '../models';
44
export type Translator = {
55
(id: string, defaultMessage: string, values?: any): string;
66
(id: string, defaultMessage: undefined, values?: any): string | undefined;
7+
(id: string, defaultMessage?: string, values?: any): string | undefined;
78
}
89

910
export type ErrorTranslator = (error: ErrorObject, translate: Translator, uischema?: UISchemaElement) => string;

0 commit comments

Comments
 (0)