getsentry / getsentry/sentry-javascript

wrapServerLoader/Action does not infer types of Route.LoaderArgs

Đang mở
#18,041 2 bình luận 1 reaction 0 người được giao Xem trên GitHub
Improvement React Router Framework
Ngôn ngữ chính
TypeScript
Star
8.7k
Fork
1.8k
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
515

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.