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

Possibly wrong submit typescript type #368

Open
akozhemiakin opened this issue Jul 21, 2020 · 0 comments · May be fixed by #488
Open

Possibly wrong submit typescript type #368

akozhemiakin opened this issue Jul 21, 2020 · 0 comments · May be fixed by #488

Comments

@akozhemiakin
Copy link

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

Currently we have the following FormApi type:

export interface FormApi<FormValues = Record<string, any>, InitialFormValues = Partial<FormValues>> {
    submit: () => Promise<FormValues | undefined> | undefined
    ...
}

What is the expected behavior?

In documentation it is stated that it should return some arbitrary object

Submits the form if there are currently no validation errors. It may return undefined or a Promise depending on the nature of the onSubmit configuration value given to the form when it was created.

() => Promise<?Object> | void

And in react-final-form docs it is stated that submit callback (its promise returning variant):

Returns a Promise<?Object> that resolves with no value on success or resolves with an Object of submission errors on failure. The reason it resolves with errors is to leave rejection for when there is a server or communications error.

I believe that submit callback is not constrained by returning the result of type FormValues | undefined.

Should not it be typed like this?

submit: () => Promise<SubmissionErrors | undefined> | undefined
@chenesan chenesan linked a pull request Dec 9, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant