TanStackT
TanStack2mo ago
10 replies
brilliant-lime

How to get ctx.meta?.loadSubsetOptions type safe?

The type of meta being Record<string, unknown> | undefined, loadSubsetOptions is typed unknown.

Is there a way to make it type safe or I should just cope with @ts-ignore?
createCollection(
    queryCollectionOptions({
        queryKey: orpc.missions.steps.answers.list.queryKey(),
        syncMode: "on-demand",
        queryFn: (ctx) => {
            // ts error: Argument of type 'unknown' is not assignable to parameter of type '{ where?: BasicExpression<boolean> | undefined; orderBy?: OrderBy | undefined; limit?: number | undefined; } | null | undefined'.
            const options = parseLoadSubsetOptions(
                ctx.meta?.loadSubsetOptions
            );
            return orpc.missions.steps.answers.list.call(options);
        },
        queryClient,
        getKey: (item) => item.id,
    })
)
Was this page helpful?