Closed Michael-1 closed 11 months ago
I found a solution with generics:
export default <Query extends {query: string}> (
query: Query,
parameters?: Record<string, unknown>
) => {
type ReturnType = InferType<Query>
Though I would prefer if GROQD would export its internal types, like BaseQuery
I would like to structure my code such that I define a query with the frontend component that is using the query’s result, and to have a library function that takes care of handling the fetching, caching and all the usual. Yet I’m having issues with correctly typing the input and output for the library function.
What would I use for
WhatTypeToUseHere
? Or how could I achieve what I want, with correct typings?