Kimblis
Kimblis4w ago

New versions doesn't fit the docs?

I just updated versions of my packages and now I get typescript errors that the my query doesn't fit with the types. It says that I'm missing initialData and queryKey for .useQuery() however docs says that the queryKey should be auto generated. No? My package versions:
"@tanstack/react-query": "^5.45.1",
"@trpc/react-query": "10.45.2",

"@tanstack/react-query": "^5.45.1",
"@trpc/react-query": "10.45.2",

Query example:
const { data: exercisesCountByDifficulty, isLoading: exercisesCountByDifficultyAreBeingLoaded } =
trpc.dashboard.getStationExercisesCountByDifficulties.useQuery(
{
stationIds,
},
{
refetchOnMount: false,
refetchOnReconnect: false,
refetchOnWindowFocus: false,
trpc: {
context: { skipBatch: true },
},
},
);
const { data: exercisesCountByDifficulty, isLoading: exercisesCountByDifficultyAreBeingLoaded } =
trpc.dashboard.getStationExercisesCountByDifficulties.useQuery(
{
stationIds,
},
{
refetchOnMount: false,
refetchOnReconnect: false,
refetchOnWindowFocus: false,
trpc: {
context: { skipBatch: true },
},
},
);
```
2 Replies
Kimblis
Kimblis4w ago
full error in batches (since message is too long) Full error:
No overload matches this call.
Overload 1 of 2, '(input: { stationIds: string[]; }, opts: DefinedUseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]>): DefinedUseTRPCQueryResult<...>', gave the following error.
Argument of type '{ refetchOnMount: false; refetchOnReconnect: false; refetchOnWindowFocus: false; trpc: { context: { skipBatch: boolean; }; }; }' is not assignable to parameter of type 'DefinedUseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]>'.
Type '{ refetchOnMount: false; refetchOnReconnect: false; refetchOnWindowFocus: false; trpc: { context: { skipBatch: boolean; }; }; }' is missing the following properties from type 'DefinedUseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]>': initialData, queryKey
Overload 2 of 2, '(input: { stationIds: string[]; }, opts?: UseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]> | undefined): UseTRPCQueryResult<...>', gave the following error.
No overload matches this call.
Overload 1 of 2, '(input: { stationIds: string[]; }, opts: DefinedUseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]>): DefinedUseTRPCQueryResult<...>', gave the following error.
Argument of type '{ refetchOnMount: false; refetchOnReconnect: false; refetchOnWindowFocus: false; trpc: { context: { skipBatch: boolean; }; }; }' is not assignable to parameter of type 'DefinedUseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]>'.
Type '{ refetchOnMount: false; refetchOnReconnect: false; refetchOnWindowFocus: false; trpc: { context: { skipBatch: boolean; }; }; }' is missing the following properties from type 'DefinedUseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]>': initialData, queryKey
Overload 2 of 2, '(input: { stationIds: string[]; }, opts?: UseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]> | undefined): UseTRPCQueryResult<...>', gave the following error.
Argument of type '{ refetchOnMount: false; refetchOnReconnect: false; refetchOnWindowFocus: false; trpc: { context: { skipBatch: boolean; }; }; }' is not assignable to parameter of type 'UseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]>'.
Property 'queryKey' is missing in type '{ refetchOnMount: false; refetchOnReconnect: false; refetchOnWindowFocus: false; trpc: { context: { skipBatch: boolean; }; }; }' but required in type 'UseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]>'
Argument of type '{ refetchOnMount: false; refetchOnReconnect: false; refetchOnWindowFocus: false; trpc: { context: { skipBatch: boolean; }; }; }' is not assignable to parameter of type 'UseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]>'.
Property 'queryKey' is missing in type '{ refetchOnMount: false; refetchOnReconnect: false; refetchOnWindowFocus: false; trpc: { context: { skipBatch: boolean; }; }; }' but required in type 'UseTRPCQueryOptions<"dashboard.getStationExercisesCountByDifficulties", { stationIds: string[]; }, { stationId: string; countByDifficulty: { Threshold: number; Satisfactory: number; Fundamental: number; Honorable: number; }; }[], { ...; }[], TRPCClientErrorLike<...>, { ...; }[]>'
Nick
Nick4w ago
you need to use trpc @next which is the v11 tag