eslint-plugin-query: @tanstack/query/exhaustive-deps is triggered for a type used in an instanceof call.
Describe the bug
I've got a query that's using instanceof to ensure that my API client is returning the expected type. The ESLint plugin is flagging this type as an unused dependency, even though that makes no sense.
Your minimal, reproducible example
Included in "Steps to reproduce"
Steps to reproduce
Note that this is using jotai-tanstack-query and this is all in TypeScript, but I assume that's irrelevant.
This reproduces the problem directly:
class SomeBaseResponse {}
class SomeResponse extends SomeBaseResponse {}
function someCall(): SomeBaseResponse {
return new SomeResponse();
}
export const someQuery = atomWithSuspenseQuery(() => ({
queryKey: ["someQuery"],
queryFn: () => {
const result = someCall();
if (result instanceof SomeResponse) {
return result;
}
throw new Error("Failed to get something");
}
}));
The ESLint plugin then gives the following error for the queryKey line:
error The following dependencies are missing in your queryKey: SomeResponse @tanstack/query/exhaustive-deps
Expected behavior
I'd expect the plugin to understand that the typename being used isn't a dependency and so not flag it.
How often does this bug happen?
Every time
Screenshots or Videos
Platform
- OS: macOS 14.4.1
- Browser: Irrelevent
- IDE: VSCode
- Plugin versions:
- "@tanstack/eslint-plugin-query": "^5.28.11",
- "eslint": "^8.57.0",
Tanstack Query adapter
react-query
TanStack Query version
5.32.0
TypeScript version
5.4.5
Additional context
No response
@Newbie012 can you take a look please ?
Should be fixed once https://github.com/TanStack/query/pull/7419 is merged