From bf73457467b39d747b8d1bc21e56f894973293e4 Mon Sep 17 00:00:00 2001 From: Alexander Konotop Date: Thu, 21 Dec 2023 17:48:05 +0200 Subject: [PATCH] Fix type resolvability for non-grpc implementation of unwrapped rpc args --- integration/wrappers-regression/wrappers-regression.ts | 2 +- src/generate-services.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/integration/wrappers-regression/wrappers-regression.ts b/integration/wrappers-regression/wrappers-regression.ts index 402d2b68c..6e5c9744f 100644 --- a/integration/wrappers-regression/wrappers-regression.ts +++ b/integration/wrappers-regression/wrappers-regression.ts @@ -34,7 +34,7 @@ export class ClockClientImpl implements Clock { } NowString(request: string | undefined): Promise { - const data = StringValue.encode({ value: request }).finish(); + const data = StringValue.encode(StringValue.fromPartial({ value: request })).finish(); const promise = this.rpc.request(this.service, "NowString", data); return promise.then((data) => StringValue.decode(_m0.Reader.create(data))); } diff --git a/src/generate-services.ts b/src/generate-services.ts index 720da7a41..2c520ec54 100644 --- a/src/generate-services.ts +++ b/src/generate-services.ts @@ -133,8 +133,9 @@ function generateRegularRpcMethod(ctx: Context, methodDesc: MethodDescriptorProt `; } - const inputValue = isValueType && !methodDesc.clientStreaming ? '{ value: request }' : 'request'; - let encode = code`${rawInputType}.encode(${inputValue}).finish()`; + let encode = isValueType && !methodDesc.clientStreaming + ? code`${rawInputType}.encode(${rawInputType}.fromPartial({ value: request })).finish()` + : code`${rawInputType}.encode(request).finish()`; let beforeRequest; if (options.rpcBeforeRequest) { beforeRequest = code`