ts-proto 1.132.1 → 1.133.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.133.0](https://github.com/stephenh/ts-proto/compare/v1.132.1...v1.133.0) (2022-11-20)
2
+
3
+
4
+ ### Features
5
+
6
+ * optional one of properties ([#705](https://github.com/stephenh/ts-proto/issues/705)) ([4c6cbb0](https://github.com/stephenh/ts-proto/commit/4c6cbb0ff71e053c634732e295ed812901d368ae))
7
+
1
8
  ## [1.132.1](https://github.com/stephenh/ts-proto/compare/v1.132.0...v1.132.1) (2022-11-15)
2
9
 
3
10
 
package/build/types.js CHANGED
@@ -320,11 +320,14 @@ exports.isScalar = isScalar;
320
320
  // properties. When useOptionals='all', all fields are translated into
321
321
  // optional properties, with the exception of map Entry key/values, which must
322
322
  // always be present.
323
+ // OneOf fields are always optional, whenever oneof=unions option not in use.
323
324
  function isOptionalProperty(field, messageOptions, options) {
324
325
  const optionalMessages = options.useOptionals === true || options.useOptionals === "messages" || options.useOptionals === "all";
325
326
  const optionalAll = options.useOptionals === "all";
326
327
  return ((optionalMessages && isMessage(field) && !isRepeated(field)) ||
327
328
  (optionalAll && !(messageOptions === null || messageOptions === void 0 ? void 0 : messageOptions.mapEntry)) ||
329
+ // don't bother verifying that oneof is not union. union oneofs generate their own properties.
330
+ isWithinOneOf(field) ||
328
331
  field.proto3Optional);
329
332
  }
330
333
  exports.isOptionalProperty = isOptionalProperty;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.132.1",
3
+ "version": "1.133.0",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",