-
Notifications
You must be signed in to change notification settings - Fork 66
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
The generated code(js) is different from what I defined in .proto file #37
Comments
@microlv You might wanna use my generator to generate with exact names. It generates typescript but you can compile it to js and use it. |
@thesayyn I don't found your example code in your project. do u miss add it to github? |
@microlv Unfortunately it doesn’t compile to ESM directly although you can use typescript to get ESM compatible js outputs from ts files. Maybe later I can add an option to get ESM-JS outputs from generated Typescript files thus you can get ESM outputs directly from the plugin. But for now, you need to compile them to js which is so easy. It will take only few minutes. |
any updates on this? this is a critical issue! |
Just speculation here: but yes, if there was a compile-time flag to allow proto generation to not mangle the variable names of repeated fields, that would be quite nice. |
Would like to add my +1 to this issue. We're using the What I don't understand is why the JS changes the keys this way, but the JSON keys in Golang don't get similarly changed: In JS:
and the same prop in go:
This means we need to manually extend the type in order to get the thing compiling correctly with keys that can be decoded when they get to the server:
|
@jamierumbelow i don't see a reason why you shouldn't use |
I thought I was – but just looked a little closer and realised I was using |
Don't forget to upstream the changes you make to the compiler according to your needs. I would appreciate help from all of you. |
We transform names to lower camelcase intentionally to match commonjs style as opposed to the lower_style that is more common in protobuf. Additionally, we add suffixes to match the types. We can't easily change this because it would be a compatibility break. |
What version of protobuf and what language are you using?
Version: v3.11.0
Language: Javascript
What operating system (Linux, Windows, ...) and version?
Windows/Linux
What runtime / compiler are you using (e.g., python version or gcc version)
protoc
What did you do?
Steps to reproduce the behavior:
2.define the .proto file liek the below code:
What did you expect to see
I want to keep my field as the same as I defined in .proto file. but I found some fields are changed.
In toObject function there are some fields are changed, like:
What did you see instead?
My field has been changed! and I want to keep it as the same as I defined it in .proto file
Anything else we should know about your project / environment
web project/ commonjs coding style/ use webpack/
The text was updated successfully, but these errors were encountered: