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

Pass Output type to Submission in onSubmit #326

Closed
wants to merge 2 commits into from

Conversation

rphlmr
Copy link

@rphlmr rphlmr commented Nov 10, 2023

Hello,

I apply this patch on my projects and i think it can be useful.

Make context.submission aware of the Output type.

Now we should be able to have intellisense with onSubmit context param.

Ex:

onSubmit(event, context) {
   // it has type
    if (context.submission.value?.step === "send-otp") {
        // do something
    }
},

Make `context.submission` aware of the `Output` type.
Pass Output type to Submission in onSubmitt
@edmundhung
Copy link
Owner

Hi @rphlmr, thanks for the PR. I would love to improve the types here but your change is not accurate because there would be default submission object returned even when you didn't provide an onValidate handler.

To fix it, we might need to introduce an additional generic to capture the submission returned by the onValidate handler or some other adjustment on this behaviour.

@edmundhung
Copy link
Owner

This should be fixed on v1 as it will not returns a default submission anymore. Thanks!

@edmundhung edmundhung closed this Jan 1, 2024
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 this pull request may close these issues.

2 participants