From 4d8187699baec96de8d0f48e90fd0dcacc82237c Mon Sep 17 00:00:00 2001 From: Stanislav Muhametsin <346799+stazz@users.noreply.github.com> Date: Wed, 14 Feb 2024 14:35:59 +0200 Subject: [PATCH] =?UTF-8?q?#129=20QoL=20improvements=20to=20typings=20of?= =?UTF-8?q?=20endpoint=20args=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …. --- endpoint-spec/package.json | 2 +- endpoint-spec/src/api.types/url.types.ts | 8 ++++---- endpoint-spec/src/implementation/app.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/endpoint-spec/package.json b/endpoint-spec/package.json index 5c8cd4c..98c5332 100644 --- a/endpoint-spec/package.json +++ b/endpoint-spec/package.json @@ -1,6 +1,6 @@ { "name": "@ty-ras/endpoint-spec", - "version": "2.2.1", + "version": "2.2.2", "author": { "name": "Stanislav Muhametsin", "email": "346799+stazz@users.noreply.github.com", diff --git a/endpoint-spec/src/api.types/url.types.ts b/endpoint-spec/src/api.types/url.types.ts index 857aed3..e4e2271 100644 --- a/endpoint-spec/src/api.types/url.types.ts +++ b/endpoint-spec/src/api.types/url.types.ts @@ -393,11 +393,11 @@ export type GetMethodArgsGeneric< TProtocolSpec extends protocol.ProtocolSpecCore, TStateSpec, > = { - context: TServerContext; state: dataBE.MaterializeRuntimeState; -} & (TProtocolSpec extends protocol.ProtocolSpecURL - ? { url: protocol.RuntimeOf } - : {}) & +} & (never extends TServerContext ? {} : { context: TServerContext }) & + (TProtocolSpec extends protocol.ProtocolSpecURL + ? { url: protocol.RuntimeOf } + : {}) & (TProtocolSpec extends protocol.ProtocolSpecQuery ? { query: protocol.RuntimeOf } : {}) & diff --git a/endpoint-spec/src/implementation/app.ts b/endpoint-spec/src/implementation/app.ts index f58cef4..eb8af8b 100644 --- a/endpoint-spec/src/implementation/app.ts +++ b/endpoint-spec/src/implementation/app.ts @@ -303,7 +303,7 @@ function newBuilderGenericImpl< ? processMethodArg : (pArgs) => { const boundMethod = processMethodArg(pArgs) ?? pArgs.boundMethod; - return ({ context: _, ...args }) => boundMethod(args as any); // eslint-disable-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unused-vars + return (args) => boundMethod(data.omit(args, "context" as any) as any); // eslint-disable-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unused-vars }; // Define resetMetadataProviders separately, as defining it inline causes problems with function overload having different argument count. const resetMetadataProviders: api.ApplicationBuilderGeneric<