fix: generate valid js code for aliased enum values#1801
fix: generate valid js code for aliased enum values#1801alexander-fenster merged 1 commit intomasterfrom
Conversation
| * @ignore | ||
| */ | ||
| function genValuePartial_fromObject(gen, field, fieldIndex, prop) { | ||
| var defaultAlreadyEmitted = false; |
There was a problem hiding this comment.
I would usually use let, but it looks like var is internally consistent.
There was a problem hiding this comment.
Yes, it's the remains of Node 4 support. We probably want a global refactor to make the code more modern.
There was a problem hiding this comment.
Hello @bcoe and @alexander-fenster,
Firstly, Thanks for developing and maintaining this amazing library.
Second, I use protobuf.js massively in IoT embedded devices without experiencing any issues.
Due to small memory footprint I use embedded Javascript engine - Duktape (ES5/5.1 complaint + some more features from ES6/7).
If it is planned to use modern syntax for feature/bug fixes, I am concerned about Duktape compatibility issues with the new code. In addition, I don't believe there are better protobuf alternatives in Javascript.
In the future, I see 2 options:
- I maintain a forked ES5/5.1 version equivalent to protobuf.js releases (which could be a nightmare)
- You’d also be maintaining another branch for ES5/5.1 syntax.
Requesting your thoughts and guidance on the same.
Thanks!
Having an aliased default value in an enum now breaks the generated JS static code:
Fixing that by making sure that the
default:clause is emitted only once. Updating the tests accordingly.