From b106d20099c87c3a7c482a0bd206ce12cbd6034f Mon Sep 17 00:00:00 2001 From: Gurpreet Atwal Date: Thu, 15 Aug 2024 05:52:47 -0700 Subject: [PATCH] fix(sveltekit): update wrapServerRouteWithSentry to respect ParamMatchers 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 --- packages/sveltekit/src/server/serverRoute.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sveltekit/src/server/serverRoute.ts b/packages/sveltekit/src/server/serverRoute.ts index a5f13f9a73ca..bd8f57a6578a 100644 --- a/packages/sveltekit/src/server/serverRoute.ts +++ b/packages/sveltekit/src/server/serverRoute.ts @@ -27,9 +27,9 @@ type PatchedServerRouteEvent = RequestEvent & { __sentry_wrapped__?: boolean }; * * @returns a wrapped version of your server route handler */ -export function wrapServerRouteWithSentry( - originalRouteHandler: (request: RequestEvent) => Promise, -): (requestEvent: RequestEvent) => Promise { +export function wrapServerRouteWithSentry( + originalRouteHandler: (request: T) => Promise, +): (requestEvent: T) => Promise { return new Proxy(originalRouteHandler, { apply: async (wrappingTarget, thisArg, args) => { const event = args[0] as PatchedServerRouteEvent;