From 30056bf1e4be37e7789aafa5ee6e372825df3a45 Mon Sep 17 00:00:00 2001 From: Kiran Mantha Date: Sun, 16 Jun 2024 18:03:52 +0530 Subject: [PATCH 1/2] Update procedure.ts to return type if it is there on procedure definition --- src/utils/procedure.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/procedure.ts b/src/utils/procedure.ts index 8881bc8b..64e8c14c 100644 --- a/src/utils/procedure.ts +++ b/src/utils/procedure.ts @@ -23,6 +23,7 @@ const getProcedureType = (procedure: OpenApiProcedure): ProcedureType => { if (procedure._def.query) return 'query'; if (procedure._def.mutation) return 'mutation'; if (procedure._def.subscription) return 'subscription'; + if (procedure._def.type) return procedure._def.type; throw new Error('Unknown procedure type'); }; From ead2c308cf595032873dc81ef75770ede58820a5 Mon Sep 17 00:00:00 2001 From: KiranMantha Date: Mon, 17 Jun 2024 17:49:52 +0530 Subject: [PATCH 2/2] updated type of OpenApiProcedure to accept type property on _def --- src/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index 71cec3ee..922d1693 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import { Procedure, ProcedureParams, Router } from '@trpc/server'; +import { Procedure, ProcedureParams, ProcedureType, Router } from '@trpc/server'; import type { RootConfig } from '@trpc/server/dist/core/internals/config'; import { TRPC_ERROR_CODE_KEY } from '@trpc/server/rpc'; import type { RouterDef } from '@trpc/server/src/core/router'; @@ -37,7 +37,7 @@ export type OpenApiMeta = TMeta & { export type OpenApiProcedure = Procedure< 'query' | 'mutation', - ProcedureParams< + { type: ProcedureType } & ProcedureParams< RootConfig<{ transformer: any; errorShape: any;