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

removeEnumPrefix generating wrong code in callsites #830

Closed
anzorbalkar opened this issue May 11, 2023 · 4 comments
Closed

removeEnumPrefix generating wrong code in callsites #830

anzorbalkar opened this issue May 11, 2023 · 4 comments

Comments

@anzorbalkar
Copy link

Hi,

I just started using the removeEnumPrefix flag and it seems to be working well to generate the actual enum, however the other callsites in the generated code are still referencing the old style naming. In other words the generated code itself is inconsistent.

Example:

// product.proto

enum Color {
  COLOR_UNSPECIFIED = 0;
  COLOR_RED = 1;
  COLOR_GREEN = 2;
  COLOR_BLUE = 3;
}

message Product {
  Color color = 1;
}

=>

// product.ts

// good; expected.
export enum Color {
  UNSPECIFIED = "COLOR_UNSPECIFIED",
  RED = "COLOR_RED",
  GREEN = "COLOR_GREEN",
  BLUE = "COLOR_BLUE",
  UNRECOGNIZED = "UNRECOGNIZED",
}

...

function createBaseProduct(): Product {
  return { color: Color.COLOR_UNSPECIFIED };  // <-- not good; not expected; does not compile.
}

Am I needing to add an additional flag to correct this or is this a bug?

@anzorbalkar anzorbalkar changed the title removeEnumPrefix generated wrong code in callsites removeEnumPrefix generating wrong code in callsites May 11, 2023
@stephenh
Copy link
Owner

Ah shoot, sorry for just getting to this, but yeah @anzorbalkar that is odd; I'm surprised no one else has gotten tripped up by this/that the original PR missed it.

If you could submit a PR to fix, that would be great! Also cc @superclaw who submitted the original removeEnumPrefix support, in case they can help out; thanks!

@superclaw
Copy link
Contributor

@anzorbalkar Could you please make a repo with minimal reproduction of this bug? Do you mean generating services from proto?

@buzap
Copy link
Collaborator

buzap commented Aug 15, 2023

I believe this is the same issue as #897, which was fixed in PR #902.

@stephenh
Copy link
Owner

Ah yep! Agreed @buzap , thanks for noticing that! Closing this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants