/** * Map utility "type" to its method signature. * Extend via module augmentation: * declare module '@plone/types' { interface UtilityTypeMap { foo: (id: string) => string } } */ export interface UtilityTypeMap { validator: ValidatorUtility; transform: (data: any) => any; fieldFactoryInitialData: (intl: any) => Record; fieldFactoryProperties: (intl: any) => Record; } export type ValidatorUtilityArgs = { value: any; field: Record; formData: any; formatMessage: (...args: any[]) => any; }; export type ValidatorUtility = ( options: ValidatorUtilityArgs, ) => string | null | undefined; type UtilityMethodFor = Type extends keyof UtilityTypeMap ? UtilityTypeMap[Type] : (...args: any[]) => any; export type Utility = Record< string, { method: UtilityMethodFor } >; type UtilitiesByMap = { [Type in keyof UtilityTypeMap]: Utility; }; export type UtilitiesConfig = UtilitiesByMap & Record;