From 6dc5189fc2974ac3f8970e25931ee9a05202cbc9 Mon Sep 17 00:00:00 2001 From: Chi-Hsuan Huang Date: Wed, 9 Feb 2022 12:40:44 +0800 Subject: [PATCH] Replace "any" type with an explicit type (https://github.com/woocommerce/woocommerce-admin/pull/8262) * Replace "any" type with an explicit type * Add types in utils and import FormInputProps to store address --- .../components/settings/general/store-address.tsx | 5 ++--- plugins/woocommerce-admin/client/utils/types.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 plugins/woocommerce-admin/client/utils/types.ts diff --git a/plugins/woocommerce-admin/client/dashboard/components/settings/general/store-address.tsx b/plugins/woocommerce-admin/client/dashboard/components/settings/general/store-address.tsx index 0033434cc71..3d24f7dcc34 100644 --- a/plugins/woocommerce-admin/client/dashboard/components/settings/general/store-address.tsx +++ b/plugins/woocommerce-admin/client/dashboard/components/settings/general/store-address.tsx @@ -14,6 +14,7 @@ import { useSelect } from '@wordpress/data'; * Internal dependencies */ import { getAdminSetting } from '~/utils/admin-settings'; +import { FormInputProps } from '~/utils/types'; const { countries } = getAdminSetting( 'dataEndpoints', { countries: {} } ); const storeAddressFields = [ @@ -322,9 +323,7 @@ export function useGetCountryStateAutofill( } type StoreAddressProps = { - // Disable reason: The getInputProps type are not provided by the caller and source. - // eslint-disable-next-line @typescript-eslint/no-explicit-any - getInputProps: any; + getInputProps: ( key: string ) => FormInputProps; setValue: ( key: string, value: string ) => void; }; diff --git a/plugins/woocommerce-admin/client/utils/types.ts b/plugins/woocommerce-admin/client/utils/types.ts new file mode 100644 index 00000000000..8281a7b87cc --- /dev/null +++ b/plugins/woocommerce-admin/client/utils/types.ts @@ -0,0 +1,12 @@ +export type FormValue = HTMLInputElement[ 'value' ]; + +// TODO: move to packages/components/Form when we convert From to TS. +export type FormInputProps = { + value: FormValue; + checked: boolean; + selected: FormValue; + onChange: ( value: FormValue ) => void; + onBlur: () => void; + className: string; + help: string | null; +};