ts-protoc-gen icon indicating copy to clipboard operation
ts-protoc-gen copied to clipboard

proto3 - required / optional fields

Open AmitM30 opened this issue 3 years ago • 4 comments

Versions of relevant software used 0.15.0

What happened I am using proto3, and after generating the typescript schema, only some fields are marked as optional. While, afaik, everything should be optional by default.

What you expected to happen

In the following definition:

syntax = "proto3";

message Location {
  string title = 1;
  string description = 2;
  Link link = 3;
}

link is marked as optional, rest required. Not sure why.

How to reproduce it (as minimally and precisely as possible):

we could use the above definition and reproduce this.

link.proto

syntax = "proto3";

message Link {
  string key = 1;
  string title = 2;
  string url = 3;
}

Full logs to relevant components

Anything else we need to know

AmitM30 avatar Sep 07 '21 07:09 AmitM30

@AmitM30 Have you solved this issue somehow? :) Thanks in advance.

davidslaby avatar Jan 17 '22 17:01 davidslaby

@AmitM30 Have you solved this issue somehow? :) Thanks in advance.

@davidslaby No. I am living with it.

AmitM30 avatar Jan 18 '22 05:01 AmitM30

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 19 '22 02:04 stale[bot]

I came here to find out which arguments we need to pass to fix this behavior as well - most of the types generated from our protos say the fields are there when they could be missing.

I would expect all of these to have | undefined added to the end of their types. Making this change now would probably be quite the breaking change, but an option and then gradual move could work?

kimroen avatar Jun 10 '22 09:06 kimroen