diff --git a/packages/protobuf-bench/README.md b/packages/protobuf-bench/README.md index 810e195e6..1f08d5a46 100644 --- a/packages/protobuf-bench/README.md +++ b/packages/protobuf-bench/README.md @@ -10,5 +10,5 @@ server would usually do. | code generator | bundle size | minified | compressed | |---------------------|------------------------:|-----------------------:|-------------------:| -| protobuf-es | 96,959 b | 41,479 b | 10,750 b | +| protobuf-es | 97,101 b | 41,461 b | 10,746 b | | protobuf-javascript | 394,384 b | 288,654 b | 45,122 b | diff --git a/packages/protobuf/src/private/util-common.ts b/packages/protobuf/src/private/util-common.ts index 1a86873db..57a64740a 100644 --- a/packages/protobuf/src/private/util-common.ts +++ b/packages/protobuf/src/private/util-common.ts @@ -38,6 +38,7 @@ export function makeUtilCommon(): Omit { t = target as AnyMessage, s = source as PartialMessage; if (s[localName] === undefined) { + // TODO if source is a Message instance, we should use isFieldSet() here to support future field presence continue; } switch (member.kind) { @@ -105,7 +106,7 @@ export function makeUtilCommon(): Omit { t[localName] = (s[localName] as any[]).map((val) => val instanceof mt ? val : new mt(val), ); - } else if (s[localName] !== undefined) { + } else { const val = s[localName]; if (mt.fieldWrapper) { if ( @@ -124,6 +125,7 @@ export function makeUtilCommon(): Omit { } } }, + // TODO use isFieldSet() here to support future field presence equals>( type: MessageType, a: T | PlainMessage | undefined | null, @@ -202,6 +204,7 @@ export function makeUtilCommon(): Omit { } }); }, + // TODO use isFieldSet() here to support future field presence clone>(message: T): T { const type = message.getType(), target = new type(), diff --git a/packages/protobuf/src/proto2.ts b/packages/protobuf/src/proto2.ts index b4daa7e0f..292be5102 100644 --- a/packages/protobuf/src/proto2.ts +++ b/packages/protobuf/src/proto2.ts @@ -29,7 +29,7 @@ export const proto2 = makeProtoRuntime( normalizeFieldInfos(source, false), ); }, - // TODO merge with proto3 and initExtensionField + // TODO merge with proto3 and initExtensionField, also see initPartial, equals, clone (target: Message): void => { for (const member of target.getType().fields.byMember()) { const name = member.localName, diff --git a/packages/protobuf/src/proto3.ts b/packages/protobuf/src/proto3.ts index b4a1035e9..31c4b05da 100644 --- a/packages/protobuf/src/proto3.ts +++ b/packages/protobuf/src/proto3.ts @@ -30,7 +30,7 @@ export const proto3 = makeProtoRuntime( normalizeFieldInfos(source, true), ); }, - // TODO merge with proto2 and initExtensionField + // TODO merge with proto2 and initExtensionField, also see initPartial, equals, clone (target: Message): void => { for (const member of target.getType().fields.byMember()) { if (member.opt) {