grpc / grpc-web

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

protoc-gen-grpc-web generated files issue #390

Open thomasamills opened 5 years ago

thomasamills commented 5 years ago

Hello,

Whilst using the protoc-gen-grpc-web plugin with --grpc-web_out set as: --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:

The resulting _pb.d.ts file contains class and namespace definitions of messages only in the top level of a message structure.

For example, with a message "Foo" in one file (foo.proto)

message Foo {
Bar b = 1 } message Bar { string msg = 1 }

And a service in a separate file (api.proto)

service API { // "Void" is an empty message rpc Run (Void) returns (Foo); }

The resulting api_pb.d.ts only contains class and namespace definitions for Foo and not Bar. However, if I were to nest Bar within Foo, it does generate the required class and namespaces.

Does anybody know how to fix this issue? Nesting each is not feasible as my message structures in my project are quite complex and messages re-used.

weilip1803 commented 5 years ago

What i did was to use commonJs version and do a const bar = require(.js) and create the bar object to feed it back to foo. The typings are pretty bad still.

thomasamills commented 5 years ago

The recent commits fixed this issue, however, some classes and names are now being duplicated.

thomasamills commented 5 years ago

Unrelated to my first post but fits within the scope of the issue name. Within the generation of the d.ts file, maps are not handled and the resulting js field types are defined as a list instead. I'm working on a fix now.