Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export generated Rpc interfaces #1115

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/generate-grpc-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function generateGrpcWebRpcType(ctx: Context, returnObservable: boolean, hasStre
const { options } = ctx;
const { useAbortSignal } = options;

chunks.push(code`interface Rpc {`);
chunks.push(code`export interface Rpc {`);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @marcaddeo , thanks for the PR!

Can you update this to conditionally add the export, i.e. something like:

  const maybeExport = options.exportCommonSymbols ? "export" : "";

Because we have some users where, when working with multiple *.proto files, these common exports can import conflicts, so they can opt to turn off the export. Thanks!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah dang, that's true. I'm one of those people who opt out of the common exports too... So now this isn't going to help me at all 😅

Will update though.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no! Sorry! :-)

Fwiw #1109 is an idea to make a shared ./ts-proto-types.ts type file that have all these common types, and be output all the time, in just one spot, in theory allowing us to kill the common exports problem.

If you're up for tackling a PR for that, that'd be amazing! 🙏


const wrapper = returnObservable ? observableType(ctx) : "Promise";
chunks.push(code`
Expand Down
2 changes: 1 addition & 1 deletion src/generate-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ export function generateRpcType(ctx: Context, hasStreamingMethods: boolean): Cod
]);
}
const chunks: Code[] = [];
chunks.push(code` interface Rpc${maybeContext} {`);
chunks.push(code` export interface Rpc${maybeContext} {`);
methods.forEach((method) => {
chunks.push(code`
${method[0]}(
Expand Down
Loading