Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer onSuccess response type from onSubmit return type #221

Open
fabian-michael opened this issue Feb 8, 2023 · 1 comment
Open

Infer onSuccess response type from onSubmit return type #221

fabian-michael opened this issue Feb 8, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@fabian-michael
Copy link

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 fabian-michael added the enhancement New feature or request label Feb 8, 2023
@fabian-michael
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant