You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Up to version v3.24.6 I was able to define our type for UseQueryOptions by only specifying the two first generics. As of version v3.25.0 I get a Typescript error because the underlying types no longer match even though the UseQueryOptions signature hasn't changed.
I suspect TS is getting hung up on the fact that refetchInterval now is able to accept a function.
Desktop (please complete the following information):
OS: Windows 10 (10.0.19042 Build 19042)
Browser: Chrome
Version: 94.0.4606.81
Additional context
Argument of type '{ enabled?: boolean | undefined; staleTime: number; refetchInterval?: number | false | ((data: SampleResponse | undefined, query: Query<SampleResponse, HttpClientResponseError, SampleResponse, QueryKey>) => number | false) | undefined; ... 30 more ...; _defaulted?: boolean | undefined; }' is not assignable to parameter of type 'Omit<UseQueryOptions<SampleResponse, HttpClientResponseError, SampleResponse, string[]>, "queryKey" | "queryFn">'.
Types of property 'refetchInterval' are incompatible.
Type 'number | false | ((data: SampleResponse | undefined, query: Query<SampleResponse, HttpClientResponseError, SampleResponse, QueryKey>) => number | false) | undefined' is not assignable to type 'number | false | ((data: SampleResponse | undefined, query: Query<SampleResponse, HttpClientResponseError, SampleResponse, string[]>) => number | false) | undefined'.
Type '(data: SampleResponse | undefined, query: Query<SampleResponse, HttpClientResponseError, SampleResponse, QueryKey>) => number | false' is not assignable to type 'number | false | ((data: SampleResponse | undefined, query: Query<SampleResponse, HttpClientResponseError, SampleResponse, string[]>) => number | false) | undefined'.
Type '(data: SampleResponse | undefined, query: Query<SampleResponse, HttpClientResponseError, SampleResponse, QueryKey>) => number | false' is not assignable to type '(data: SampleResponse | undefined, query: Query<SampleResponse, HttpClientResponseError, SampleResponse, string[]>) => number | false'.
Types of parameters 'query' and 'query' are incompatible.
Type 'Query<SampleResponse, HttpClientResponseError, SampleResponse, string[]>' is not assignable to type 'Query<SampleResponse, HttpClientResponseError, SampleResponse, QueryKey>'.
The types of 'options.queryFn' are incompatible between these types.
Type 'QueryFunction<SampleResponse, string[]> | undefined' is not assignable to type 'QueryFunction<SampleResponse, QueryKey> | undefined'.
Type 'QueryFunction<SampleResponse, string[]>' is not assignable to type 'QueryFunction<SampleResponse, QueryKey>'.
Type 'QueryKey' is not assignable to type 'string[]'.
Type 'string' is not assignable to type 'string[]'.ts(2345)
but those approaches have all the flaws as outlined in the other comment: select won't work, and consumers of that custom hook can still override queryKeys and queryFn. If that's okay for your use-case, this is a good alternative.
Describe the bug
Up to version v3.24.6 I was able to define our type for UseQueryOptions by only specifying the two first generics. As of version v3.25.0 I get a Typescript error because the underlying types no longer match even though the UseQueryOptions signature hasn't changed.
I suspect TS is getting hung up on the fact that refetchInterval now is able to accept a function.
Please advise.
To Reproduce
Expected behavior
Screenshots

Desktop (please complete the following information):
Additional context
Dependencies
The text was updated successfully, but these errors were encountered: