add the missing checkNullConditionnal code in the "GenObjApi" function when the field is scalar optional (#7114)

This commit is contained in:
anov21
2022-02-22 12:34:37 +08:00
committed by GitHub
parent 9c52ec3744
commit 433312c55a

View File

@@ -1079,6 +1079,9 @@ class TsGenerator : public BaseGenerator {
if (has_create) {
pack_func_create_call += field_offset_val;
} else {
if (field.IsScalarOptional()) {
pack_func_create_call += " if (" + field_offset_val + " !== null)\n ";
}
pack_func_create_call += " " + struct_name + ".add" +
MakeCamel(field.name) + "(builder, " +
field_offset_val + ");\n";