Optimistic updates typescript example does not work locally
Describe the bug
Trying to run the optimistic updates typescript examples in the example folder on my local machine gives the following error: Argument of type 'UseQueryOptions<Todos, AxiosError<any>, TData, QueryKey> | undefined' is not assignable to parameter of type 'Omit<UseQueryOptions<Todos, AxiosError<any>, TData, "todos">, "queryKey" | "queryFn"> | undefined'.
Your minimal, reproducible example
The optimistic updates typescript example in the examples folder
Steps to reproduce
- Clone repository
- Run
yarnin theexamples\optimistic-updates-typescriptfolder - Run yarn dev, open the browser
Expected behavior
The app runs like it does in the example in the docs
How often does this bug happen?
Every time
Screenshots or Videos

Platform
Windows 11 Home 21H2 Edge 98.0.1108.56 (Official build) (64-bit) Yarn v1.22.15 NPM 6.14.15 Node 14.18.2
react-query version
Commit eb4e863cf44d30ef8b936068fce09f9632def68a (latest at the moment)
TypeScript version
No response
Additional context
No response
The example was built with react-query 3.5.1, which is why it works in codesandbox.
for the latest version, the options need to omit queryKey and queryFn:
function useTodos<TData = Todos>(
options?: Omit<
UseQueryOptions<Todos, AxiosError, TData>,
"queryKey" | "queryFn"
>
) {
return useQuery("todos", fetchTodos, options);
}
I wouldn't make such an abstraction anymore, as it's pretty wide. I'll adapt the example for v4. The whole TodoCounter thing is unnecessary in v4 when tracked queries are the new default.
I fixed and simplified the example for v4: 61fd5397