Closed achingbrain closed 2 years ago
:tada: This PR is included in version protons-runtime-v3.1.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
:tada: This PR is included in version protons-v5.1.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
:tada: This issue has been resolved in version 3.0.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
Proto3 language guide states:
When decoding objects, create an object with all non-optional fields set to the default values, then overwrite them during decoding.
Given that we create arrays for repeated fields there's no need to check for their existence before returning the deserialized object.
The only weird part in all this is message fields. The spec says that any non-optional field is required, but it also says that the default value for a sub-message is to be unset and that the actual value there is language-dependent and links to some language guides which don't include JavaScript - I've used
undefined
here. The upshot of this is that you can have a non-optional field with a default value ofundefined
which essentially makes it optional. Nice. At the moment we throw if the sub-message is not present in the protobuf if the field is required though in a future change we may wish to ignore the spec and initialise the sub-message to an instance of it's type with default values set 🤷.Refs #43