Skip to content

Commit

Permalink
Don't check for default entries in toJson when using proto2
Browse files Browse the repository at this point in the history
  • Loading branch information
tresabhi committed Nov 9, 2024
1 parent c90f285 commit c9fc51a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 49 deletions.
4 changes: 2 additions & 2 deletions integration/extensions/test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions integration/map-long-optional/test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 36 additions & 42 deletions integration/proto2-long/simple.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export function notDefaultCheck(
case FieldDescriptorProto_Type.TYPE_INT64:
case FieldDescriptorProto_Type.TYPE_SINT64:
case FieldDescriptorProto_Type.TYPE_SFIXED64:
if (options.forceLong === LongOption.LONG && !isJsTypeFieldOption(options, field)) {
if (options.forceLong === LongOption.LONG && !isJsTypeFieldOption(options, field) && ctx.currentFile.isProto3Syntax) {
return code`${maybeNotUndefinedAnd} !${place}.equals(${defaultValue(ctx, field)})`;
} else {
return code`${maybeNotUndefinedAnd} ${place} !== ${defaultValue(ctx, field)}`;
Expand Down

0 comments on commit c9fc51a

Please sign in to comment.