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 committed Jan 19, 2023
1 parent 5a84cd3 commit d6f82a4
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 d6f82a4

Please sign in to comment.