Get type of QueryResult from queryOptions? #8651
Answered
by
TkDodo
Faithfinder
asked this question in
Q&A
-
Is there a helper type like this? const todoQueryOptions = (params) => queryOptions({ queryKey, queryFn});
type TodoQueryResult = InferQueryResult<ReturnType<typeof todoQueryOptions>> |
Beta Was this translation helpful? Give feedback.
Answered by
TkDodo
Mar 18, 2025
Replies: 2 comments 3 replies
-
Also just ran into this. Haven't been able to figure out a solution |
Beta Was this translation helpful? Give feedback.
0 replies
-
why do you need that? Inference is complicated 😅 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this works fine with just
type TodoQueryOptions = ReturnType<typeof todoQueryOptions>
:https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgRwK4FMoE8DyYbAQB2AzgDRyonoCKG2cAvnAGZQQhwDkAAjAIakBAYwDWAeijp+wmAFo0mLFwBQoSLDgAqOPxJwAStNmt2nLlJkxVK4cRLwYEACYQ6SvAXtwAvHAAUwM4AXHBEqCAARpgAlL4AfCj0uPiEpP4IKnBJSgDS6FihANpcTq5cFEEAumRZOdgAYkSh-nE+iQAKZsDUAHRSJBAANgBu6IHOMSqMMQDcKiowWGDocAAqLm7Jnmn6fkYwqFBEa8voADxLKxAscGVbHqn28QssqESyaXAAgmBgrYgFtk7EI4EUghRqDAAJLOKq+QzGGC9KjoADKAhg4wADFNgfZHJsdt4-Pd3NhiekglM6lJDscAnVsudnMARi9spy4OcALJYADCHEgRHQRHgECepB8CHulJIzHEHM553ErPZdSmjFe70+xDgfMF4GIopg-jA7DAJFCCAlXlIoQ2rnJKTt8rimTqIIc9SwCNRzrNFpIvVtuxp2TpRyIYVQQyG0xUQA