T
TanStack14mo ago
foreign-sapphire

What are the correct types for UseQueryOptions that will make select infer correctly?

Trying to make this work without using partial , else select will emit TS error if returned data is mutated and doesnt equal the exact type.
export const getProjectsQuery = <TData = { projects: Array<Project> }>(
options?: Omit<UseQueryOptions<TData>, "queryKey" | "queryFn">,
) => {
return useQuery<TData>({
queryKey: ["projects"],
queryFn: fetchProjects,
...options,
});
};
export const getProjectsQuery = <TData = { projects: Array<Project> }>(
options?: Omit<UseQueryOptions<TData>, "queryKey" | "queryFn">,
) => {
return useQuery<TData>({
queryKey: ["projects"],
queryFn: fetchProjects,
...options,
});
};
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?