protocolbuffers / protobuf-javascript

BSD 3-Clause "New" or "Revised" License
365 stars 67 forks source link

Incorrect signature for setter functions in .d.ts #22

Closed ApoorvGuptaAi closed 2 years ago

ApoorvGuptaAi commented 4 years ago

What version of protobuf and what language are you using? Version: libprotoc 3.12.1 Language: Javascript

What operating system (Linux, Windows, ...) and version? Ubuntu 18.04

What runtime / compiler are you using (e.g., python version or gcc version) Node 10

What did you do? Steps to reproduce the behavior:

  1. Create example.proto.
  2. Generate javascript/typescript bindings with:
    protoc \
    --proto_path=$SRC_ROOT/protocol/ \
    --js_out=import_style=commonjs:$OUT_DIR  \
    --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:$OUT_DIR \
    example.proto

What did you expect to see example_pb.d.ts generates a signature for setXXX fields that return the proto.

export class Example extends jspb.Message {
  getId(): string;
  setId(value: string): Example;
  ...
}

What did you see instead? Generated signature returns void.

export class Example extends jspb.Message {
  getId(): string;
  setId(value: string): void;
  ...
}

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Note the actual generated file returns a value:

proto.Example.prototype.setId = function(value) {
  return jspb.Message.setProto3StringField(this, 1, value);
};
NfNitLoop commented 3 years ago

@ApoorvGuptaAi The --grpc-web_out option invokes an external tool by the name of protoc-gen-grpc-web, which is not included in this repository.

It's likely this: https://github.com/grpc/grpc-web#code-generator-plugin

(I see import_style=commonjs+dts documented there as well.) That's likely a more appropriate place to report this bug. Though, do note that they mark that feature as experimental.

dibenede commented 2 years ago

We don't generate .d.ts, so this may be a grpc-web issue.

dibenede commented 2 years ago

Please re-file against https://github.com/grpc/grpc-web