* Replace "any" type with an explicit type

* Add types in utils and import FormInputProps to store address
This commit is contained in:
Chi-Hsuan Huang 2022-02-09 12:40:44 +08:00 committed by GitHub
parent 83e1addd82
commit 6dc5189fc2
2 changed files with 14 additions and 3 deletions

View File

@ -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;
};

View File

@ -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;
};