Skip to content

Commit

Permalink
conditional export (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
austin-liou committed Feb 16, 2024
1 parent 9fdce05 commit a605a24
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -872,14 +872,20 @@ function makeComparisonUtils() {
return { isObject, isSet };
}

function makeNiceGrpcServerStreamingMethodResult() {
function makeNiceGrpcServerStreamingMethodResult(options: Options) {
const NiceGrpcServerStreamingMethodResult = conditionalOutput(
"ServerStreamingMethodResult",
code`
export type ServerStreamingMethodResult<Response> = {
[Symbol.asyncIterator](): AsyncIterator<Response, void>;
};
`,
options.outputIndex
? code`
type ServerStreamingMethodResult<Response> = {
[Symbol.asyncIterator](): AsyncIterator<Response, void>;
};
`
: code`
export type ServerStreamingMethodResult<Response> = {
[Symbol.asyncIterator](): AsyncIterator<Response, void>;
};
`,
);

return { NiceGrpcServerStreamingMethodResult };
Expand Down

0 comments on commit a605a24

Please sign in to comment.