Skip to content

Commit 9e2d40d

Browse files
allow to type Params of RequestHandler (#3989)
* allow to type `Params` of `RequestHandler` * mark change as breaking Co-authored-by: Rich Harris <[email protected]>
1 parent f223f91 commit 9e2d40d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Diff for: .changeset/proud-cooks-relax.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[breaking] allow providing `Params` type argument for `RequestHandler`

Diff for: packages/kit/types/index.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@ export interface PrerenderErrorHandler {
340340
}): void;
341341
}
342342

343-
export interface RequestEvent {
343+
export interface RequestEvent<Params = Record<string, string>> {
344344
request: Request;
345345
url: URL;
346-
params: Record<string, string>;
346+
params: Params;
347347
locals: App.Locals;
348348
platform: Readonly<App.Platform>;
349349
}
@@ -354,8 +354,8 @@ export interface RequestEvent {
354354
* that method. Note that since 'delete' is a reserved word in
355355
* JavaScript, delete handles are called 'del' instead.
356356
*/
357-
export interface RequestHandler<Output extends Body = Body> {
358-
(event: RequestEvent): MaybePromise<
357+
export interface RequestHandler<Params = Record<string, string>, Output extends Body = Body> {
358+
(event: RequestEvent<Params>): MaybePromise<
359359
Either<Output extends Response ? Response : EndpointOutput<Output>, Fallthrough>
360360
>;
361361
}

0 commit comments

Comments
 (0)