getsentry / getsentry/sentry-javascript

wrapServerLoader/Action does not infer types of Route.LoaderArgs

Aperta
#18,041 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
Improvement React Router Framework
Lingua principale
TypeScript
Stelle
8.7k
Fork
1.8k
Merge medio
1g 17h
PR unite (30g)
515

Descrizione

### 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_

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.