From 2b27f537f9fc9ff21214f74cac80e6610b4338eb Mon Sep 17 00:00:00 2001 From: Jan Jakes Date: Tue, 10 May 2022 14:09:35 +0200 Subject: [PATCH] Add types for custom font-family select options [MAILPOET-4323] --- .../components/font_family_settings.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mailpoet/assets/js/src/form_editor/components/font_family_settings.tsx b/mailpoet/assets/js/src/form_editor/components/font_family_settings.tsx index 4801f59133..fbd122638e 100644 --- a/mailpoet/assets/js/src/form_editor/components/font_family_settings.tsx +++ b/mailpoet/assets/js/src/form_editor/components/font_family_settings.tsx @@ -15,6 +15,14 @@ const standardFonts = [ 'Verdana', ]; +type Option = { + key: string; + name: string; + selectable: boolean; + value?: string; + style?: CSSProperties; +}; + type Props = { onChange: (value: string | undefined) => void; value?: string; @@ -42,7 +50,7 @@ export function FontFamilySettings({ cursor: 'default', marginLeft: 16, }); - const options = [ + const options: Option[] = [ { key: MailPoet.I18n.t('formFontsDefaultTheme'), name: MailPoet.I18n.t('formFontsDefaultTheme'), @@ -90,8 +98,9 @@ export function FontFamilySettings({ { - if (selected.selectedItem.selectable) { - onChange(selected.selectedItem.value as string); + const selectedItem = selected.selectedItem as Option; + if (selectedItem.selectable) { + onChange(selectedItem.value); } }} value={selectedValue}