This change only affects the users of the tsconfig option strictNullChecks, others can completely ignore it.
In typescript types of getters and setters match exactly. This is ok, cos when a field always has value (!canHaveNullValue), assigning undefined to it makes no sense: the getter of the field will always return some non-null value, so the code bellow will print 0.
let x = undefined;
msg.int64 = x; // msg.int is a proto3 int64 field
x = msg.int64;
console.log(x); // will print 0, might be confusing
The implication is that you cannot assign undefined to a field, that always returns non-null value (if you are using strictNullChecks:true). This is a problem when dealing with optional fields, so clear_* methods were introduced. The plugin generates them for all fields, that had has_* method generated. Those methods are described in the official doc https://github.com/protocolbuffers/protobuf/blob/main/docs/field_presence.md
This change only affects the users of the tsconfig option
strictNullChecks
, others can completely ignore it.In typescript types of getters and setters match exactly. This is ok, cos when a field always has value (
!canHaveNullValue
), assigning undefined to it makes no sense: the getter of the field will always return some non-null value, so the code bellow will print0
.The implication is that you cannot assign undefined to a field, that always returns non-null value (if you are using
strictNullChecks:true
). This is a problem when dealing withoptional
fields, soclear_*
methods were introduced. The plugin generates them for all fields, that hadhas_*
method generated. Those methods are described in the official doc https://github.com/protocolbuffers/protobuf/blob/main/docs/field_presence.md