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

Feature request: Allow prefixing generated type names #1017

Open
csimmons0 opened this issue Nov 19, 2024 · 1 comment
Open

Feature request: Allow prefixing generated type names #1017

csimmons0 opened this issue Nov 19, 2024 · 1 comment

Comments

@csimmons0
Copy link

csimmons0 commented Nov 19, 2024

It would be great if we could simply add a line to buf.gen.yaml that made the generator add a prefix to the generated types' names. For example, I would just say typesPrefix: "Pb" in the yaml file, and then for this proto enum:

enum Foo {
  ...
}

the generated TS code would be

export enum PbFoo {
  ...
}

Same for message types and their TS classes. The motivation for this request is to avoid name collisions between generated TS types and manually-written types that correspond to them. Without this feature I have to manually alias names when I import them, as in

import {Foo as PbFoo} from ...
@JosephusPaye
Copy link

This would be quite useful to have. In our case we're generating wrapper classes that provide an API similar to v1 and protobuf-js, and having the base types prefixed would be handy.

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

2 participants