Skip to content

Commit

Permalink
implicitly allow Response object instance (#3697)
Browse files Browse the repository at this point in the history
* conditionally check Output as Response

* add changset

* docs
  • Loading branch information
ignatiusmb committed Feb 3, 2022
1 parent 6e86c4a commit ccc780b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-rockets-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Allow Response object to be returned without properties showing up in object constructor
4 changes: 3 additions & 1 deletion documentation/docs/01-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ interface Fallthrough {
}

export interface RequestHandler<Output extends Body = Body> {
(event: RequestEvent): MaybePromise<Either<Response | EndpointOutput<Output>, Fallthrough>>;
(event: RequestEvent): MaybePromise<
Either<Output extends Response ? Response : EndpointOutput<Output>, Fallthrough>
>;
}
```

Expand Down
4 changes: 3 additions & 1 deletion packages/kit/types/endpoint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ export interface Fallthrough {
}

export interface RequestHandler<Output extends Body = Body> {
(event: RequestEvent): MaybePromise<Either<Response | EndpointOutput<Output>, Fallthrough>>;
(event: RequestEvent): MaybePromise<
Either<Output extends Response ? Response : EndpointOutput<Output>, Fallthrough>
>;
}

0 comments on commit ccc780b

Please sign in to comment.