getsentry / getsentry/sentry-javascript

wrapServerLoader/Action does not infer types of Route.LoaderArgs

Open
#18,041 2 comments 1 reaction 0 assignees View on GitHub
Improvement React Router Framework
Dominant language
TypeScript
Stars
8.7k
Forks
1.8k
Avg merge
1d 17h
Merged PRs (30d)
515

Description

### Problem Statement

The arguments being inferred in the wrapServerLoader/Action function for the loaderFn/actionFn are generic and don't get the Route.LoaderArgs as type making accessing the params object not typed anymore.

```
export declare function wrapServerLoader(options: SpanOptions | undefined, loaderFn: (args: LoaderFunctionArgs) => Promise): (args: LoaderFunctionArgs) => Promise;
```

```
/routes/payouts.$payout-id/route.ts
export const loader = Sentry.wrapServerLoader({}, async ({ request, params }) => {
const payoutId = params['payout-id']; // string | undefined -> should be string
});
```

### Solution Brainstorm

Add a generic type to the loaderFn/actionFn so that the params object has the right inferred types.

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.