grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.51k stars 766 forks source link

Why a repeated type in proto generated as ***sList in TS? Can it RESPECT the protobuf definition? #1257

Closed uynap closed 2 years ago

uynap commented 2 years ago

If I have a proto definite like :

message Foo{
  repeated Goals goals = 1;

Then the plugin will give me something below:

export namespace Foo {
  export type AsObject = {
    goalsList: Array<Goals.AsObject>,
  }
}

But what I expect is goals: Array<Goals.AsObject> instead of goalsList: Array<Goals.AsObject>. Is there a way to stop the plugin doing this "smart" thing?

sampajano commented 2 years ago

Thanks for the question :)

From what i understand, the TS generates does not define the API, but rather it generates the definitions matching the underlying generated code by the protobuf compiler.

Per documentation here: https://web.archive.org/web/20200928202524/https://developers.google.com/protocol-buffers/docs/reference/javascript-generated#any= (JS documentation is temporarily missing currently as mentioned here), the List suffix seems to be part of the protobuf API spec.

So sorry for the inconveniences but this is not fixable on grpc-web side :)