Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile with Proto3 optional fields #987

Closed
alancleary opened this issue Nov 13, 2020 · 2 comments
Closed

Can't compile with Proto3 optional fields #987

alancleary opened this issue Nov 13, 2020 · 2 comments

Comments

@alancleary
Copy link

I see that support for Proto3 optional fields was added in pull #884, which was included in release 1.2.1. However, when I try to generate TypeScript files from a protobuf file containing optional fields I receive an error:

helloworld.proto: is a proto3 file that contains optional fields, but code
generator --js_out hasn't been updated to support optional fields in proto3.
Please ask the owner of this code generator to support proto3 optional.

I'm using protoc version 3.12.4 and grpc-web version 1.2.1.

Here's the protoc command:

$ protoc -I=. helloworld.proto --experimental_allow_proto3_optional \
  --js_out=import_style=commonjs,binary:. \
  --grpc-web_out=import_style=typescript,mode=grpcwebtext:.

And here's helloworld.proto:

syntax = "proto3";

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

message HelloRequest {
  optional string name = 1;
}

message HelloReply {
  string message = 1;
}

Hopefully this is an error on my part, otherwise I guess this could be considered a feature request. Any thoughts on what might be happening here?

@stanley-cheung
Copy link
Collaborator

I believe for --js_out, which is the part of the standard protoc distribution (not a grpc-web distribution), that part of the plugin has only been updated since version 3.13.0, but I am not sure. In any case, please check with the protocolbuffers repo for that particular plugin.

@alancleary alancleary changed the title Can't compile woth Proto3 optional fields Can't compile with Proto3 optional fields Nov 13, 2020
@alancleary
Copy link
Author

Thanks for the quick reply, @stanley-cheung. I didn't realize --js_out is part of the protoc distribution. I upgraded protoc to version 3.13.0 and indeed it compiled with Proto3 optional fields. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants