getsentry / getsentry/sentry-javascript
wrapServerLoader/Action does not infer types of Route.LoaderArgs
- 主要语言
- TypeScript
- 星标
- 8.7k
- 派生
- 1.8k
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 515
描述
### 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_
贡献指南
评估
这个 Issue 还没有评估数据。