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
proto-loader-gen-types Typename templates #2183
Conversation
|
Can you expand some more on what your use case is for this, and also why you excluded enums? |
@murgatroid99 The enum is a special case because it's both a type and a value. Parent messages seem to reference the enum directly. export interface TestMessage {
'enum'?: (test_v1_Enum | keyof typeof test_v1_Enum);
}
export interface TestMessage__Output {
'enum': (keyof typeof test_v1_Enum);
} It might be worth treating enums like messages in that we create both an input and an output version, and the input/output parent message would point to the corresponding one. I wanted to leave that for a different PR for now. |
Hey @murgatroid99 have you had a chance to look at this? I'm open to any feedback and suggestions :) thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not confident that inputName
is called everywhere it is needed. Since the default behavior is to leave the string unchanged, the current tests will not catch if it is omitted anywhere. Can you add a test with a different --inputTemplate
option?
Please also create a PR to add information about these new options to this file.
- Allow for customizing the naming pattern for both restricted and permissive types
@murgatroid99 Thanks for the feedback! I've addressed your comments and updated the golden tests to use the new flags. |
FYI - prefixing interfaces with "I" conflicts with Hungarian notation commonly misused in other parts of the TS ecosystem. Suggest prefixing with "In"/"Out" rather than "I/O" |
It's just an example. This won't actually change any of the generated type names by default. Nevertheless if @murgatroid99 prefers different values for the golden test I can change it. |
It doesn't matter to me. That test is mainly there to verify the consistency of the generator output. |
@murgatroid99 How can I help push this forward? |
Sorry about the delay here. |
This is out in version 0.7.3 |
Enums and filenames are left untouched