T
TanStack•8mo ago
flat-fuchsia

UseQuery return type set to any after typescript-eslint update

Hi ! I have a simple useQuery hook that receive for queryFn a typed function, after updating typescript-eslint the return value of the hook is now set to any. Is there a solution for this ? 😢
const {
isError, // THIS IS NOW ANY
isLoading, // THIS IS NOW ANY
isFetching, // THIS IS NOW ANY
refetch: refetchTasks, // THIS IS NOW ANY
data: tasks, // THIS IS NOW ANY :'(
error,
} = useQuery({
queryKey: [`tasks`, session?.user?.id],
queryFn: () => fetchTasks(session?.user?.id), // fetchTasks return Promise<Task[]>
enabled: !!session?.user?.id,

})
const {
isError, // THIS IS NOW ANY
isLoading, // THIS IS NOW ANY
isFetching, // THIS IS NOW ANY
refetch: refetchTasks, // THIS IS NOW ANY
data: tasks, // THIS IS NOW ANY :'(
error,
} = useQuery({
queryKey: [`tasks`, session?.user?.id],
queryFn: () => fetchTasks(session?.user?.id), // fetchTasks return Promise<Task[]>
enabled: !!session?.user?.id,

})
8 Replies
flat-fuchsia
flat-fuchsia•8mo ago
Disabling/Pausing Queries | TanStack Query React Docs
If you ever want to disable a query from automatically running, you can use the enabled = false option. The enabled option also accepts a callback that returns a boolean. When enabled is false: If the...
flat-fuchsia
flat-fuchsiaOP•8mo ago
I don't think that's the issue. I've tried removing 'enabled' parameter but I still get the response as any, it doesnt seem to be a condition issue I think it was typed properly before I updated typescript-eslint to latest
foreign-sapphire
foreign-sapphire•8mo ago
please show a typescript playground
flat-fuchsia
flat-fuchsiaOP•8mo ago
Uh I tried on a codesandbox and it worked properly, seems like I just had to restart vscode Thanks for the help
flat-fuchsia
flat-fuchsia•8mo ago
No description
wise-white
wise-white•8mo ago
Most of the weird issue with eslint showing funny type all over the place after upgrading, just need a restart of vs-code
exotic-emerald
exotic-emerald•8mo ago
Ctrl+Shift+P and restarting the eslint server most often works too (and is a little quicker than a full restart) I find myself using this a few times a day
No description

Did you find this page helpful?