Skip to content

Commit

Permalink
Allow for other syntax options than "proto2" or "proto3"
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-traverse committed Jul 26, 2024
1 parent 9bcc006 commit fda51db
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cli/targets/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,15 @@ function isOptional(field, syntax) {
return field.options != null && field.options["proto3_optional"] === true;

// In proto2, fields are explicitly optional if they are not part of a map, array or oneOf group
return field.optional && !(field.partOf || field.repeated || field.map);
if (syntax === "proto2")
return field.optional && !(field.partOf || field.repeated || field.map);

throw new Error("Unknown proto syntax: [" + syntax + "]");
}

function isOptionalOneOf(oneof, syntax) {

if (syntax !== "proto3")
if (syntax === "proto2")
return false;

if (oneof.fieldsArray == null || oneof.fieldsArray.length !== 1)
Expand Down

0 comments on commit fda51db

Please sign in to comment.