type TFormHookPerformValidation<formValuesT> = (params: {
formValues: formValuesT,
debugName?: string,
}) => {
isPassing: boolean,
fieldErrors: Record<string, unknown>,
formError: string,
}
const performValidation: TFormHookPerformValidation = params => {
// Do something based on params and return
return {
isPassing: true,
fieldErrors: {},
formError: ''
}
}
TFormHookPerformValidation
expects 1 generics, but when defining functions the type assignment will come first before the generics setup, so how can we accept generics in performValidation
function and pass it to TFormHookPerformValidation
.
Note: I can use Parameters
and ReturnType
but I would like to know if it’s possible to assign the function type itself.