Skip to content

Commit

Permalink
fix(sveltekit): update wrapServerRouteWithSentry to respect ParamMatc…
Browse files Browse the repository at this point in the history
…hers

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
  • Loading branch information
gurpreetatwal authored Aug 15, 2024
1 parent 5c08d03 commit 956ca90
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/sveltekit/src/server/serverRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response>,
): (requestEvent: RequestEvent) => Promise<Response> {
export function wrapServerRouteWithSentry<T extends RequestEvent>(
originalRouteHandler: (request: T) => Promise<Response>,
): (requestEvent: T) => Promise<Response> {
return new Proxy(originalRouteHandler, {
apply: async (wrappingTarget, thisArg, args) => {
const event = args[0] as PatchedServerRouteEvent;
Expand Down

0 comments on commit 956ca90

Please sign in to comment.