Skip to content

Commit fda51db

Browse files
Allow for other syntax options than "proto2" or "proto3"
1 parent 9bcc006 commit fda51db

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cli/targets/static.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,15 @@ function isOptional(field, syntax) {
384384
return field.options != null && field.options["proto3_optional"] === true;
385385

386386
// In proto2, fields are explicitly optional if they are not part of a map, array or oneOf group
387-
return field.optional && !(field.partOf || field.repeated || field.map);
387+
if (syntax === "proto2")
388+
return field.optional && !(field.partOf || field.repeated || field.map);
389+
390+
throw new Error("Unknown proto syntax: [" + syntax + "]");
388391
}
389392

390393
function isOptionalOneOf(oneof, syntax) {
391394

392-
if (syntax !== "proto3")
395+
if (syntax === "proto2")
393396
return false;
394397

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

0 commit comments

Comments
 (0)