File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -395,11 +395,10 @@ function buildType(ref, type) {
395395 var jsType = toJsType ( field ) ;
396396 var nullable = false ;
397397
398- // New behaviour - fields explicitly marked as optional and members of a one-of are nullable
399- // Maps and repeated fields are not explicitly optional, they default to empty instances
398+ // New behaviour - respect explicit optional semantics in both proto2 and proto3
400399 if ( config [ "force-optional" ] ) {
401- if ( isOptional ( field , syntax ) || field . partOf ) {
402- jsType = jsType + "|null|undefined " ;
400+ if ( isOptional ( field , syntax ) || field . partOf || field . repeated || field . map ) {
401+ jsType = jsType + "|null" ;
403402 nullable = true ;
404403 }
405404 }
@@ -439,7 +438,7 @@ function buildType(ref, type) {
439438 var jsType = toJsType ( field ) ;
440439
441440 // New behaviour - fields explicitly marked as optional and members of a one-of are nullable
442- // Maps and repeated fields are not explicitly optional , they default to empty instances
441+ // Maps and repeated fields are not nullable , they default to empty instances
443442 if ( config [ "force-optional" ] ) {
444443 if ( isOptional ( field , syntax ) || field . partOf )
445444 jsType = jsType + "|null|undefined" ;
You can’t perform that action at this time.
0 commit comments