Gh∅st
Gh∅st
TtRPC
Created by Gh∅st on 2/17/2024 in #❓-help
Create a typescript type that refers to a useQuery hook dynamically
I'm trying to create a typescript type that generically refers to a useQuery hook (e.g. I am trying to do type CommonHookFn = (name:string)=>MyCustomType, except I need the equivalent of a useQuery hook where I can templatize the inputs/outputs). From exploring the types under the hood of trpc, I think I need to use ProcedureUseQuery<TProcedure, TPath> to do this, but I can't figure out what I would put in to TProcesure/TPath to tell it that I'm looking for a Query with specific input/output types.. (e.g need a hook that takes a string as n input, and returns MyCustomType for its data) Does anyone know how to create a type like this? environment: Node 19, typescript 5.3.3, @trpc/client, @trpc/server, @trpc/next: 10.45.1 @tanstack/react-query: 4.36.1
7 replies