felte icon indicating copy to clipboard operation
felte copied to clipboard

Infer onSuccess response type from onSubmit return type

Open fabian-michael opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. The response type of the onSuccess hook is currently unknown and can't be overridden.

I get the following error message in VS Code

Types of parameters 'response' and 'response' are incompatible.
        Type 'unknown' is not assignable to type 'LoginResponse'

Describe the solution you'd like The onSuccess response type should be inferred from the return type of the onSubmit function.

Describe alternatives you've considered Alternatively an additional type parameter on the createForm function that's unknown or any by default just like the Data type param for the onSubmit function.

fabian-michael avatar Feb 08 '23 20:02 fabian-michael

Tried to wrap my head around this. I think inferring the type from onSubmit return type is impossible. But as for that my TS knowledge is a bit limited. So the only way to achieve this might be an additional type param for createForm which could be used as the return type of onSubmit and the response param type of onSuccess.

fabian-michael avatar Feb 08 '23 21:02 fabian-michael