Add VS Code Intellisense to custom useQuery Hook #1803
-
I have created a custom hook based off of
I want to add intellisense for the I have tried importing
But I end up getting an import error. Is there any way around this? Just straight out of the way I want to mention that I am a complete stranger to Any help is highly appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I think you can import useQueryOptions directly from react-query, but maybe this only works in typescript: |
Beta Was this translation helpful? Give feedback.
-
This actually worked! I'll post my solution here in case anybody needs it.
|
Beta Was this translation helpful? Give feedback.
-
I had similar requirements, but I also use eslint
|
Beta Was this translation helpful? Give feedback.
-
I did this, just reimported type definition /**
* @typedef {import(react-query).UseQueryResult} UseQueryResult
*/
/**
* ReactQuery wrapper to fetch categories info
* @param {string} category - category
* @param {object} options - extra params
* @returns {UseQueryResult<{label: string, value: string}[], unknown>} result
*/ |
Beta Was this translation helpful? Give feedback.
This actually worked! I'll post my solution here in case anybody needs it.
import { useQuery, UseQueryOptions, QueryKey } from "react-query";