diff --git a/apps/meteor/app/api/server/ApiClass.spec.ts b/apps/meteor/app/api/server/ApiClass.spec.ts index 4edc2dd12d23c..6e94afa417a8e 100644 --- a/apps/meteor/app/api/server/ApiClass.spec.ts +++ b/apps/meteor/app/api/server/ApiClass.spec.ts @@ -58,4 +58,23 @@ describe('ExtractRoutesFromAPI', () => { >; true as ExpectedFunctionSignature; }); + it('Should extract correct function signature when body is not present', () => { + type APIWithNeverQuery = APIClass< + '/v1', + { + method: 'POST'; + path: '/v1/endpoint.test'; + response: { + 200: ValidateFunction<{ + test: string[]; + }>; + }; + authRequired: true; + } + >; + type ExpectedFunctionSignature = Expect< + ShallowEqual['/v1/endpoint.test']['POST'], () => { test: string[] }> + >; + true satisfies ExpectedFunctionSignature; + }); }); diff --git a/apps/meteor/app/api/server/ApiClass.ts b/apps/meteor/app/api/server/ApiClass.ts index e81788e6ec4a9..7e26752c7bc69 100644 --- a/apps/meteor/app/api/server/ApiClass.ts +++ b/apps/meteor/app/api/server/ApiClass.ts @@ -84,7 +84,9 @@ type ConvertToRoute = { ) => ExtractValidation['response'][200]> : K2 extends 'POST' ? ( - params: ExtractValidation['body']>, + ...args: [ExtractValidation['body']>] extends [never] + ? [params?: never] + : [params: ExtractValidation['body']>] ) => ExtractValidation< 200 extends keyof Extract['response'] ? Extract['response'][200]