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) {
395
395
var jsType = toJsType ( field ) ;
396
396
var nullable = false ;
397
397
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
400
399
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" ;
403
402
nullable = true ;
404
403
}
405
404
}
@@ -439,7 +438,7 @@ function buildType(ref, type) {
439
438
var jsType = toJsType ( field ) ;
440
439
441
440
// 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
443
442
if ( config [ "force-optional" ] ) {
444
443
if ( isOptional ( field , syntax ) || field . partOf )
445
444
jsType = jsType + "|null|undefined" ;
You can’t perform that action at this time.
0 commit comments