Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lucky-humans-make.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: correctly type the `result` of `form` remote functions that do not accept data
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/app/server/remote/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { convert_formdata, flatten_issues } from '../../../utils.js';
*
* @template Output
* @overload
* @param {() => Output} fn
* @param {() => MaybePromise<Output>} fn
* @returns {RemoteForm<void, Output>}
* @since 2.27
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/kit/test/types/remote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ function form_tests() {
f6.input!['array[0].array[]'] = [''];
// @ts-expect-error
f6.input!['array[0].prop'] = 123;

// doesn't use data
// eslint-disable-next-line @typescript-eslint/require-await --- we are testing that the async function does not cause `result` to be typed as a Promise
const f7 = form(async () => ({ success: true }));
f7.result?.success === true;
}
form_tests();

Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3061,7 +3061,7 @@ declare module '$app/server' {
*
* @since 2.27
*/
export function form<Output>(fn: () => Output): RemoteForm<void, Output>;
export function form<Output>(fn: () => MaybePromise<Output>): RemoteForm<void, Output>;
/**
* Creates a form object that can be spread onto a `<form>` element.
*
Expand Down
Loading