Skip to content

Commit a7f13cd

Browse files
authored
[fix] update type for enhance action (#7629)
fixes #7628
1 parent 40a68de commit a7f13cd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/honest-eyes-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[fix] add Promise return type to the `enhance` action

packages/kit/types/ambient.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ declare module '$app/environment' {
9595
declare module '$app/forms' {
9696
import type { ActionResult } from '@sveltejs/kit';
9797

98+
type MaybePromise<T> = T | Promise<T>;
99+
98100
export type SubmitFunction<
99101
Success extends Record<string, unknown> | undefined = Record<string, any>,
100102
Invalid extends Record<string, unknown> | undefined = Record<string, any>
@@ -104,7 +106,7 @@ declare module '$app/forms' {
104106
form: HTMLFormElement;
105107
controller: AbortController;
106108
cancel(): void;
107-
}) =>
109+
}) => MaybePromise<
108110
| void
109111
| ((opts: {
110112
form: HTMLFormElement;
@@ -115,7 +117,8 @@ declare module '$app/forms' {
115117
* @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission.
116118
*/
117119
update(options?: { reset: boolean }): Promise<void>;
118-
}) => void);
120+
}) => void)
121+
>;
119122

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

0 commit comments

Comments
 (0)