Skip to content

Commit

Permalink
fix(sveltekit): Update wrapServerRouteWithSentry to respect ParamMa…
Browse files Browse the repository at this point in the history
…tchers (#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
  • Loading branch information
gurpreetatwal authored Oct 9, 2024
1 parent 2c3f09c commit ed2e556
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 ed2e556

Please sign in to comment.