Skip to content

wrapServerLoader/Action does not infer types of Route.LoaderArgs #18041

@AndresDJonge

Description

@AndresDJonge

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<T>(options: SpanOptions | undefined, loaderFn: (args: LoaderFunctionArgs) => Promise<T>): (args: LoaderFunctionArgs) => Promise<T>;
/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

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions