Skip to content

Commit ed2e556

Browse files
fix(sveltekit): Update wrapServerRouteWithSentry to respect ParamMatchers (#13390)
SvelteKit narrows the type of `event.params` based on ParamMatchers that are defined in the path, by making the function generic we can respect the narrowed type
1 parent 2c3f09c commit ed2e556

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/sveltekit/src/server/serverRoute.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ type PatchedServerRouteEvent = RequestEvent & { __sentry_wrapped__?: boolean };
2727
*
2828
* @returns a wrapped version of your server route handler
2929
*/
30-
export function wrapServerRouteWithSentry(
31-
originalRouteHandler: (request: RequestEvent) => Promise<Response>,
32-
): (requestEvent: RequestEvent) => Promise<Response> {
30+
export function wrapServerRouteWithSentry<T extends RequestEvent>(
31+
originalRouteHandler: (request: T) => Promise<Response>,
32+
): (requestEvent: T) => Promise<Response> {
3333
return new Proxy(originalRouteHandler, {
3434
apply: async (wrappingTarget, thisArg, args) => {
3535
const event = args[0] as PatchedServerRouteEvent;

0 commit comments

Comments
 (0)