Skip to content

Commit

Permalink
[fix] update type for enhance action (#7629)
Browse files Browse the repository at this point in the history
fixes #7628
  • Loading branch information
eltigerchino committed Nov 14, 2022
1 parent 40a68de commit a7f13cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-eyes-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] add Promise return type to the `enhance` action
7 changes: 5 additions & 2 deletions packages/kit/types/ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ declare module '$app/environment' {
declare module '$app/forms' {
import type { ActionResult } from '@sveltejs/kit';

type MaybePromise<T> = T | Promise<T>;

export type SubmitFunction<
Success extends Record<string, unknown> | undefined = Record<string, any>,
Invalid extends Record<string, unknown> | undefined = Record<string, any>
Expand All @@ -104,7 +106,7 @@ declare module '$app/forms' {
form: HTMLFormElement;
controller: AbortController;
cancel(): void;
}) =>
}) => MaybePromise<
| void
| ((opts: {
form: HTMLFormElement;
Expand All @@ -115,7 +117,8 @@ declare module '$app/forms' {
* @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission.
*/
update(options?: { reset: boolean }): Promise<void>;
}) => void);
}) => void)
>;

/**
* This action enhances a `<form>` element that otherwise would work without JavaScript.
Expand Down

0 comments on commit a7f13cd

Please sign in to comment.