diff --git a/src/createTRPCJotai.ts b/src/createTRPCJotai.ts index 601dea9..323770e 100644 --- a/src/createTRPCJotai.ts +++ b/src/createTRPCJotai.ts @@ -6,8 +6,8 @@ import type { AnyTRPCQueryProcedure, AnyTRPCSubscriptionProcedure, AnyTRPCRouter, - ProcedureArgs, - ProcedureRouterRecord, + TRPCRouterRecord, + TRPCProcedureOptions, inferProcedureInput, inferProcedureOutput, } from '@trpc/server'; @@ -73,7 +73,7 @@ const atomWithMutation = ( path: string[], getClient: (get: Getter) => TClient, ) => { - type Args = ProcedureArgs; + type Args = [inferProcedureInput, TRPCProcedureOptions]; type Output = inferProcedureOutput; const mutationAtom = atom( null as Output | null, @@ -124,16 +124,16 @@ const atomWithSubscription = < type QueryResolver = { ( - getInput: AsyncValueOrGetter[0]>, - getOptions?: ValueOrGetter[1]>, + getInput: AsyncValueOrGetter>, + getOptions?: ValueOrGetter, getClient?: (get: Getter) => TClient, ): WritableAtom>, [], void>; ( getInput: AsyncValueOrGetter< - ProcedureArgs[0] | typeof DISABLED + inferProcedureInput | typeof DISABLED >, getOptions?: ValueOrGetter< - ProcedureArgs[1] & { disabledOutput?: undefined } + TRPCProcedureOptions & { disabledOutput?: undefined } >, getClient?: (get: Getter) => TClient, ): WritableAtom< @@ -143,10 +143,10 @@ type QueryResolver = { >; ( getInput: AsyncValueOrGetter< - ProcedureArgs[0] | typeof DISABLED + inferProcedureInput | typeof DISABLED >, getOptions: ValueOrGetter< - ProcedureArgs[1] & { disabledOutput: DisabledOutput } + TRPCProcedureOptions & { disabledOutput: DisabledOutput } >, getClient?: (get: Getter) => TClient, ): WritableAtom< @@ -160,13 +160,13 @@ type MutationResolver = ( getClient?: (get: Getter) => TClient, ) => WritableAtom< inferProcedureOutput | null, - [ProcedureArgs], + [[inferProcedureInput, TRPCProcedureOptions]], Promise> >; type SubscriptionResolver = ( - getInput: ValueOrGetter[0]>, - getOptions?: ValueOrGetter[1]>, + getInput: ValueOrGetter>, + getOptions?: ValueOrGetter, getClient?: (get: Getter) => TClient, ) => Atom>>; @@ -188,7 +188,7 @@ type DecorateProcedure< : never; type DecoratedProcedureRecord< - TProcedures extends ProcedureRouterRecord, + TProcedures extends TRPCRouterRecord, TClient, > = { [TKey in keyof TProcedures]: TProcedures[TKey] extends AnyTRPCRouter