I am trying to understand this TypeScript signature from react-hook-forms
:
handleSubmit: <TSubmitFieldValues extends FieldValues = TFieldValues>(onValid: SubmitHandler<TSubmitFieldValues>, onInvalid?: SubmitErrorHandler<TFieldValues>) => (e?: React.BaseSyntheticEvent) => Promise<void>;
Especially, but not only I want to understand:
What does the equals sign in the generic type mean?
<TSubmitFieldValues extends FieldValues = TFieldValues>
How can there be two arrows in the signature?
[removed for shortening] => (e?: React.BaseSyntheticEvent) => Promise<void>
Would be great if someone could explain the signature step-by-step, thanks!