bufbuild / protobuf-es

Protocol Buffers for ECMAScript. The only JavaScript Protobuf library that is fully-compliant with Protobuf conformance tests.
Apache License 2.0
960 stars 55 forks source link

V2: Make DescField.presence available for all fields #822

Closed timostamm closed 1 month ago

timostamm commented 1 month ago

The property DescField.presence tells whether a field tracks presence, but only for singular fields. This change makes it available for all fields. The values match with the documentation, which should be helpful for users who want to take a closer look at the schema.

The property is also available for extension descriptors. It's not well documented, but implicit presence (e.g. a proto3 singular scalar field) does not apply to extensions. Otherwise, setting an extension value 0 would be ambigous.

timostamm commented 1 month ago

@srikrsna-buf, the presence and other properties of DescField/DescExtension are computed eagerly (that wasn't the case some time ago), and I can't think of a way that the kludge we use in the extension container should cause any more problems. So I think we should keep the extension container.