Giter Site home page Giter Site logo

Comments (4)

stephenh avatar stephenh commented on July 24, 2024

Hi @bhollis ; well I put up #1043 , lets see if you're right 🤞 :-)

from ts-proto.

stephenh avatar stephenh commented on July 24, 2024

Okay, @bhollis I did the basic minimum of bumping ts-proto-descriptors--is that going to do what you want? I'm slightly curious if we should have turned on a proto2-specific build option, but I'm not sure. Thanks!

from ts-proto.

stephenh avatar stephenh commented on July 24, 2024

🎉 This issue has been resolved in version 1.176.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from ts-proto.

bhollis avatar bhollis commented on July 24, 2024

Thanks for doing that! Unfortunately I was wrong - it wasn't as simple as just releasing the newest version. Even when removing disableProto2Optionals, fields still aren't set when they are at their default value. Here's the change when removing disableProto2Optionals:

    toJSON(message: EnumValueDescriptorProto): unknown {
     const obj: any = {};
-    if (message.name !== "") {
+    if (message.name !== undefined && message.name !== "") {
       obj.name = message.name;
     }
-    if (message.number !== 0) {
+    if (message.number !== undefined && message.number !== 0) {
       obj.number = Math.round(message.number);
     }
     if (message.options !== undefined) {

You can see that the optional fields aren't set when the value is not undefined, when I think they should be.

I can switch over to protobuf-es for this task, so this isn't urgent, but I really prefer ts-proto's approach to generated code in general. This is my first time having to deal with proto2 semantics.

Thanks for the project! If I get some free time I might try to file a PR to fix this, though I have some other things I'd probably want to try first.

from ts-proto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.