getsentry / getsentry/sentry-javascript

wrapServerLoader/Action does not infer types of Route.LoaderArgs

オープン
#18,041 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る
Improvement React Router Framework
主要言語
TypeScript
スター
8.7k
フォーク
1.8k
平均マージ
1日 17時間
マージ済み PR(30日)
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 はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。