@@ -841,13 +841,11 @@ void PrintProtoDtsMessage(Printer* printer, const Descriptor* desc,
841
841
" set$js_field_name$(value?: $js_field_type$): "
842
842
" $class_name$;\n " );
843
843
}
844
- if (field->has_optional_keyword () ||
845
- (field->type () == FieldDescriptor::TYPE_MESSAGE &&
846
- !field->is_repeated () && !field->is_map ())) {
844
+ if (field->has_presence ()) {
847
845
printer->Print (vars, " has$js_field_name$(): boolean;\n " );
848
846
}
849
- if (field->type () == FieldDescriptor::TYPE_MESSAGE || field-> has_optional_keyword () ||
850
- field->is_repeated () || field->is_map ()) {
847
+ if (field->type () == FieldDescriptor::TYPE_MESSAGE ||
848
+ field->has_presence () || field-> is_repeated () || field->is_map ()) {
851
849
printer->Print (vars, " clear$js_field_name$(): $class_name$;\n " );
852
850
}
853
851
if (field->is_repeated () && !field->is_map ()) {
@@ -867,14 +865,12 @@ void PrintProtoDtsMessage(Printer* printer, const Descriptor* desc,
867
865
printer->Print (" \n " );
868
866
}
869
867
870
- for (int i = 0 ; i < desc->oneof_decl_count (); i++) {
871
- const OneofDescriptor* oneof = desc->oneof_decl (i);
872
- if (!oneof->is_synthetic ()) {
873
- vars[" js_oneof_name" ] = ToUpperCamel (ParseLowerUnderscore (oneof->name ()));
874
- printer->Print (
875
- vars, " get$js_oneof_name$Case(): $class_name$.$js_oneof_name$Case;\n " );
876
- printer->Print (" \n " );
877
- }
868
+ for (int i = 0 ; i < desc->real_oneof_decl_count (); i++) {
869
+ const OneofDescriptor *oneof = desc->real_oneof_decl (i);
870
+ vars[" js_oneof_name" ] = ToUpperCamel (ParseLowerUnderscore (oneof->name ()));
871
+ printer->Print (
872
+ vars, " get$js_oneof_name$Case(): $class_name$.$js_oneof_name$Case;\n " );
873
+ printer->Print (" \n " );
878
874
}
879
875
880
876
printer->Print (
@@ -904,8 +900,7 @@ void PrintProtoDtsMessage(Printer* printer, const Descriptor* desc,
904
900
}
905
901
vars[" js_field_name" ] = js_field_name;
906
902
vars[" js_field_type" ] = AsObjectFieldType (field, file);
907
- if ((field->type () != FieldDescriptor::TYPE_MESSAGE && !field->has_optional_keyword ()) ||
908
- field->is_repeated ()) {
903
+ if (!field->has_presence ()) {
909
904
printer->Print (vars, " $js_field_name$: $js_field_type$,\n " );
910
905
} else {
911
906
printer->Print (vars, " $js_field_name$?: $js_field_type$,\n " );
0 commit comments