Skip to content

Commit

Permalink
Improve Translator type
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sdirix authored and lucas-koehler committed Jan 20, 2023
1 parent 0334763 commit ede7d61
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/core/src/i18n/i18nTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { JsonSchema, UISchemaElement } from '../models';
export type Translator = {
(id: string, defaultMessage: string, values?: any): string;
(id: string, defaultMessage: undefined, values?: any): string | undefined;
(id: string, defaultMessage?: string, values?: any): string | undefined;
}

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

0 comments on commit ede7d61

Please sign in to comment.