Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include _unknownFields as a field #806

Merged
merged 1 commit into from
Mar 26, 2023
Merged

feat: include _unknownFields as a field #806

merged 1 commit into from
Mar 26, 2023

Conversation

davidzeng0
Copy link
Contributor

@davidzeng0 davidzeng0 commented Mar 24, 2023

Makes _unknownFields a part of messages for easier access
Field left as optional as to not break existing code
Also uses for in as it is marginally faster than Object.keys
Conformant to initializeFieldsAsUndefined:

  • false -> _unknownFields always created
  • true -> _unknownFields created on use

@davidzeng0
Copy link
Contributor Author

ts-proto-descriptors would need an update that follows for the change to _unknownFields

@davidzeng0 davidzeng0 marked this pull request as draft March 24, 2023 08:23
@davidzeng0 davidzeng0 marked this pull request as ready for review March 24, 2023 08:29
Copy link
Owner

@stephenh stephenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This is a good idea. Thanks!

);
delete (message.options as any)["_unknownFields"];
messageOptions = encodedOptionsToOptions(ctx, ".google.protobuf.MessageOptions", message.options._unknownFields);
delete message.options._unknownFields;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me awhile to figure out why this wasn't failing CI....

It looks like our CI process right now doesn't actually type-check until the release step, which is unintentional.

That said, I like this change, so 🤷 I'm going to try and push it through and then follow up with a ts-proto-descriptors bump, as you mentioned in the PR description.

@stephenh stephenh merged commit 6b4ba39 into stephenh:main Mar 26, 2023
stephenh pushed a commit that referenced this pull request Mar 26, 2023
# [1.144.0](v1.143.0...v1.144.0) (2023-03-26)

### Bug Fixes

* Temporarily put anys back to release. ([c6f189e](c6f189e))

### Features

* include _unknownFields as a field ([#806](#806)) ([6b4ba39](6b4ba39))
@stephenh
Copy link
Owner

🎉 This PR is included in version 1.144.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants