From 4a15839943b501af750b9d142dba2cb3889b4617 Mon Sep 17 00:00:00 2001 From: Austin Liou Date: Thu, 15 Feb 2024 20:12:38 -0800 Subject: [PATCH] fix: conditional export (#1003) --- src/main.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main.ts b/src/main.ts index a6468fadb..c199528b2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -436,7 +436,7 @@ export function makeUtils(options: Options): Utils { ...makeTimestampMethods(options, longs, bytes), ...longs, ...makeComparisonUtils(), - ...makeNiceGrpcServerStreamingMethodResult(), + ...makeNiceGrpcServerStreamingMethodResult(options), ...makeGrpcWebErrorClass(bytes), ...makeExtensionClass(options), ...makeAssertionUtils(bytes), @@ -872,14 +872,20 @@ function makeComparisonUtils() { return { isObject, isSet }; } -function makeNiceGrpcServerStreamingMethodResult() { +function makeNiceGrpcServerStreamingMethodResult(options: Options) { const NiceGrpcServerStreamingMethodResult = conditionalOutput( "ServerStreamingMethodResult", - code` - export type ServerStreamingMethodResult = { - [Symbol.asyncIterator](): AsyncIterator; - }; - `, + options.outputIndex + ? code` + type ServerStreamingMethodResult = { + [Symbol.asyncIterator](): AsyncIterator; + }; + ` + : code` + export type ServerStreamingMethodResult = { + [Symbol.asyncIterator](): AsyncIterator; + }; + `, ); return { NiceGrpcServerStreamingMethodResult };