For example with ReactQuery's useQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>
, I want do like;
type QueryTypeParams = [Record<string, number>, unknown, unknown, "aKey" as const]
const {data} = useQuery<...QueryTypeParams>(
"anotherKey", // <- expects typescript error
() => {...}
)
But the compiler saids
Variable 'QueryTypeParams' implicitly has an 'any' type.
at where I use spread operator.
Is there any way to pass generics parameters at once?
Thanks in advance.
CodePudding user response:
Unfortunately, I do not think it is possible to pass generics parameters at once. You have to provide every type separately.
CodePudding user response:
This is not possible at the moment but there is a discussion about this feature on GitHub.