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(plugin): optional fields for oneof properties #549

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Larkooo
Copy link
Contributor

@Larkooo Larkooo commented Apr 15, 2022

addresses issue #548

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.

Great, thanks for the PR @Larkooo !

@@ -655,134 +655,134 @@ export const protoMetadata: ProtoMetadata = {
path: [4, 0],
span: [50, 0, 53, 1],
leadingComments:
' Wrapper message for `double`.\n\n The JSON representation for `DoubleValue` is JSON number.\n',
' Wrapper message for `double`.\r\n\r\n The JSON representation for `DoubleValue` is JSON number.\r\n',
Copy link
Owner

Choose a reason for hiding this comment

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

@Larkooo FWIW these changes (and the *.bin file changes) might be from running proto2bin:local instead of the docker-based proto2bin?

We used to have a lot of churn on these files from contributors having different versions of protoc installed on their machines, but in theory the docker-based setup that @boukeversteegh put in place should have removed this churn.

Can you try the docker-based commands and see if it resolves these differences? Or were you already doing that, and we still have some non-determinism issues?

@@ -0,0 +1,6831 @@
Arguments:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems that this file got included in the commit accidentally

@boukeversteegh
Copy link
Collaborator

I think it might be worthwhile to add a simple test that only instantiates an object of a type with one-of fields, and omits a field.

If we ever break this feature, the TS file won't compile.

for example, in oneof-properties-tests:

  it('allows omitting fields', () => {
      let msg: PleaseChoose = {
         name: 'foo',
      }
  });

@stephenh stephenh force-pushed the main branch 4 times, most recently from cdf2835 to 7017d4c Compare May 28, 2022 17:39
@SteveVaknin
Copy link

Hi @Larkooo, very strong work!
This can be super useful.

Are you planning to continue working on it?

@scott-lc
Copy link

scott-lc commented Nov 1, 2022

Just ran into this issue today. Anything I can do to help get the PR merged?

@stephenh
Copy link
Owner

stephenh commented Nov 6, 2022

@scott-lc yeah, would be great if you wanted to pick this up; just scanning the PR, I think the issues would be to:

a) See the PR comment about running yarn proto2bin to hopefully remove all of the *.bin files as changed files in the PR

b) Remove the yarn-error.log from the PR

c) Rebase the PR onto the latest main

d) Update one of the integration-tests/* projects to have a schema that reproduces the issue and has a test case that shows the codegen output continues to work as you expect; i.e. @boukeversteegh had suggested this has a starting place:

https://github.com/stephenh/ts-proto/blob/8769ef2ad01d53edc2d373201afeab8ca7403885/integration/oneof-properties/oneof-properties-test.ts

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

5 participants