Skip to content

fix: accept FormData as ReadOnlyFormData #1256

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

Merged
merged 2 commits into from
Apr 28, 2021
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/gorgeous-radios-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Allow FormData to be passed as RequestHandler type Body argument
4 changes: 3 additions & 1 deletion packages/kit/types/helper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ interface ReadOnlyFormData extends Iterator<[string, string]> {
}

export type BaseBody = string | Buffer | ReadOnlyFormData;
export type ParameterizedBody<Body = unknown> = BaseBody & Body;
export type ParameterizedBody<Body = unknown> = Body extends FormData
? ReadOnlyFormData
: BaseBody & Body;

// TODO we want to differentiate between request headers, which
// always follow this type, and response headers, in which
Expand Down