Closed achingbrain closed 1 year ago
cc @fryorcraken
Nice!
Do you have a test that confirms that if a singular field has a default value, then it is not encoded over the wire? As I understand protobufjs always encodes the fields over the wire the test may not be easy to do.
Yes, I've just added one here
:tada: This PR is included in version protons-v7.0.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:
As per
proto3
's language guide:This means that all
proto3
fields are effectively optional when writing, so it's relatively easy to implement by accepting aPartial
version of the message interface for encoding.When reading messages singular fields are initialized to their default values when reading and optional values are not so the plain non-
Partial
interface can be returned.This also has the nice side effect of not requring the user to pass empty lists/maps for
repeated
andmap
fields which never really felt right. These values are initted to their empty forms when reading messages from the wire.Fixes #42
BREAKING CHANGE: codecs now accept a
Partial
object so ts definitions will need to be regenerated from.proto
files to ensure the now-optional values for singular fields are handled correctly