Skip to content

Commit

Permalink
allow to type Params of RequestHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanhofer committed Feb 21, 2022
1 parent 667a565 commit b45336e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-cooks-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

allow to type `Params` of `RequestHandler`
8 changes: 4 additions & 4 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,16 @@ export interface PrerenderErrorHandler {
}): void;
}

export interface RequestEvent {
export interface RequestEvent<Params = Record<string, string>> {
request: Request;
url: URL;
params: Record<string, string>;
params: Params;
locals: App.Locals;
platform: Readonly<App.Platform>;
}

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

0 comments on commit b45336e

Please sign in to comment.