diff --git a/src/client/index.ts b/src/client/index.ts index d4681e8..28cd350 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -30,11 +30,12 @@ function createNuxtProxyDecoration(name: string, clie const path = pathCopy.join('.') - // @ts-expect-error: Additional options - const [input, { trpc, ...asyncDataOptions }] = args + const [input, otherOptions] = args const queryKey = getQueryKey(path, input) + const { trpc, ...asyncDataOptions } = otherOptions || {} as any + return useAsyncDataWithError(queryKey, () => (client as any)[path][lastArg](input, trpc), asyncDataOptions) }) } diff --git a/src/client/types.ts b/src/client/types.ts index ce57457..8b6807e 100644 --- a/src/client/types.ts +++ b/src/client/types.ts @@ -1,4 +1,4 @@ -import type { TRPCClientErrorLike } from '@trpc/client' +import type { TRPCClientErrorLike, TRPCRequestOptions } from '@trpc/client' import type { AnyMutationProcedure, AnyProcedure, @@ -33,7 +33,7 @@ export type DecorateProcedure< PickKeys extends KeyOfRes = KeyOfRes, >( input: inferProcedureInput, - opts?: AsyncDataOptions, + opts?: AsyncDataOptions & { trpc: TRPCRequestOptions }, ) => AsyncData, PickKeys>, TRPCClientErrorLike> } : TProcedure extends AnyMutationProcedure ? { mutate: < @@ -42,7 +42,7 @@ export type DecorateProcedure< PickKeys extends KeyOfRes = KeyOfRes, >( input: inferProcedureInput, - opts?: AsyncDataOptions, + opts?: AsyncDataOptions & { trpc: TRPCRequestOptions }, ) => AsyncData, PickKeys>, TRPCClientErrorLike> } : never