File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff 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
390393function 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 )
You can’t perform that action at this time.
0 commit comments