From 2d2834af56b74f2d346d072d5846246c48264147 Mon Sep 17 00:00:00 2001 From: Jimmyzm Date: Fri, 15 Mar 2024 17:57:25 +0800 Subject: [PATCH] fix: add generic parameter to fix type error when using `default` option. --- src/client/types.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/client/types.ts b/src/client/types.ts index d19fc3c..df3a30f 100644 --- a/src/client/types.ts +++ b/src/client/types.ts @@ -60,9 +60,10 @@ export type DecorateProcedure< DataE = TRPCClientErrorLike, DataT = ResT, PickKeys extends KeysOf = KeysOf, + DefaultT = null, >( input: MaybeRefOrGetter>, - opts?: AsyncDataOptions & { + opts?: AsyncDataOptions & { trpc?: TRPCRequestOptions /** * The custom unique key to use. @@ -70,15 +71,16 @@ export type DecorateProcedure< */ queryKey?: string }, - ) => AsyncData | null, DataE>, + ) => AsyncData | DefaultT, DataE>, useLazyQuery: < ResT = inferTransformedProcedureOutput, DataE = TRPCClientErrorLike, DataT = ResT, PickKeys extends KeysOf = KeysOf, + DefaultT = null, >( input: MaybeRefOrGetter>, - opts?: Omit, 'lazy'> & { + opts?: Omit, 'lazy'> & { trpc?: TRPCRequestOptions /** * The custom unique key to use. @@ -86,7 +88,7 @@ export type DecorateProcedure< */ queryKey?: string }, - ) => AsyncData | null, DataE>, + ) => AsyncData | DefaultT, DataE>, query: Resolver } : TProcedure extends AnyMutationProcedure ? { mutate: Resolver @@ -95,11 +97,12 @@ export type DecorateProcedure< DataE = TRPCClientErrorLike, DataT = ResT, PickKeys extends KeysOf = KeysOf, + DefaultT = null, >( - opts?: Omit, 'lazy'> & { + opts?: Omit, 'lazy'> & { trpc?: TRPCRequestOptions }, - ) => AsyncData | null, DataE> & { + ) => AsyncData | DefaultT, DataE> & { /** * The function to call to trigger the mutation. */