Skip to content

Commit

Permalink
fix: migrate TRPCProcedureOptions + inferProcedureInput - ProcedureAr…
Browse files Browse the repository at this point in the history
…gs has been removed
  • Loading branch information
lukeramsden committed Aug 2, 2024
1 parent edf4062 commit 05cc87c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/createTRPCJotai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type {
AnyTRPCQueryProcedure,
AnyTRPCSubscriptionProcedure,
AnyTRPCRouter,
ProcedureArgs,
ProcedureRouterRecord,
TRPCRouterRecord,
TRPCProcedureOptions,
inferProcedureInput,
inferProcedureOutput,
} from '@trpc/server';
Expand Down Expand Up @@ -73,7 +73,7 @@ const atomWithMutation = <TProcedure extends AnyTRPCMutationProcedure, TClient>(
path: string[],
getClient: (get: Getter) => TClient,
) => {
type Args = ProcedureArgs<TProcedure['_def']>;
type Args = [inferProcedureInput<TProcedure>, TRPCProcedureOptions];
type Output = inferProcedureOutput<TProcedure>;
const mutationAtom = atom(
null as Output | null,
Expand Down Expand Up @@ -124,16 +124,16 @@ const atomWithSubscription = <

type QueryResolver<TProcedure extends AnyTRPCProcedure, TClient> = {
(
getInput: AsyncValueOrGetter<ProcedureArgs<TProcedure['_def']>[0]>,
getOptions?: ValueOrGetter<ProcedureArgs<TProcedure['_def']>[1]>,
getInput: AsyncValueOrGetter<inferProcedureInput<TProcedure>>,
getOptions?: ValueOrGetter<TRPCProcedureOptions>,
getClient?: (get: Getter) => TClient,
): WritableAtom<Promise<inferProcedureOutput<TProcedure>>, [], void>;
(
getInput: AsyncValueOrGetter<
ProcedureArgs<TProcedure['_def']>[0] | typeof DISABLED
inferProcedureInput<TProcedure> | typeof DISABLED
>,
getOptions?: ValueOrGetter<
ProcedureArgs<TProcedure['_def']>[1] & { disabledOutput?: undefined }
TRPCProcedureOptions & { disabledOutput?: undefined }
>,
getClient?: (get: Getter) => TClient,
): WritableAtom<
Expand All @@ -143,10 +143,10 @@ type QueryResolver<TProcedure extends AnyTRPCProcedure, TClient> = {
>;
<DisabledOutput>(
getInput: AsyncValueOrGetter<
ProcedureArgs<TProcedure['_def']>[0] | typeof DISABLED
inferProcedureInput<TProcedure> | typeof DISABLED
>,
getOptions: ValueOrGetter<
ProcedureArgs<TProcedure['_def']>[1] & { disabledOutput: DisabledOutput }
TRPCProcedureOptions & { disabledOutput: DisabledOutput }
>,
getClient?: (get: Getter) => TClient,
): WritableAtom<
Expand All @@ -160,13 +160,13 @@ type MutationResolver<TProcedure extends AnyTRPCProcedure, TClient> = (
getClient?: (get: Getter) => TClient,
) => WritableAtom<
inferProcedureOutput<TProcedure> | null,
[ProcedureArgs<TProcedure['_def']>],
[[inferProcedureInput<TProcedure>, TRPCProcedureOptions]],
Promise<inferProcedureOutput<TProcedure>>
>;

type SubscriptionResolver<TProcedure extends AnyTRPCProcedure, TClient> = (
getInput: ValueOrGetter<ProcedureArgs<TProcedure['_def']>[0]>,
getOptions?: ValueOrGetter<ProcedureArgs<TProcedure['_def']>[1]>,
getInput: ValueOrGetter<inferProcedureInput<TProcedure>>,
getOptions?: ValueOrGetter<TRPCProcedureOptions>,
getClient?: (get: Getter) => TClient,
) => Atom<inferObservableValue<inferProcedureOutput<TProcedure>>>;

Expand All @@ -188,7 +188,7 @@ type DecorateProcedure<
: never;

type DecoratedProcedureRecord<
TProcedures extends ProcedureRouterRecord,
TProcedures extends TRPCRouterRecord,
TClient,
> = {
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyTRPCRouter
Expand Down

0 comments on commit 05cc87c

Please sign in to comment.