ts-proto icon indicating copy to clipboard operation
ts-proto copied to clipboard

feat(plugin): optional fields for oneof properties

Open Larkooo opened this issue 3 years ago • 4 comments

addresses issue #548

Larkooo avatar Apr 15 '22 04:04 Larkooo

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',
      }
  });

boukeversteegh avatar May 01 '22 19:05 boukeversteegh

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

Are you planning to continue working on it?

SteveVaknin avatar Jun 30 '22 14:06 SteveVaknin

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

scott-lc avatar Nov 01 '22 15:11 scott-lc

@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!

stephenh avatar Nov 06 '22 15:11 stephenh