protobuf-javascript icon indicating copy to clipboard operation
protobuf-javascript copied to clipboard

Unable to access extensions from JavaScript

Open mitar opened this issue 7 years ago • 3 comments

We use code like this to encode a version of the gRPC protocol:

import "google/protobuf/descriptor.proto";

extend google.protobuf.FileOptions {
    string protocol_version = 51000;
}

option (protocol_version) = "0.1.0";

And in Python, one can access it using:

import test_service_pb2
version = test_service_pb2.DESCRIPTOR.GetOptions().Extensions[test_service_pb2.protocol_version]

But it seems there is no way to access extensions from JavaScript code?

mitar avatar Aug 23 '17 18:08 mitar

Is this still the case? I am trying to write a protoc compiler in JS and I am similarly unable to get the extensions here (I believe).

ebenoist avatar Mar 26 '18 21:03 ebenoist

The issue is here: https://github.com/protocolbuffers/protobuf-javascript/blob/main/generator/js_generator.cc#L432 . We should just delete the function.

dibenede avatar Sep 30 '22 22:09 dibenede

hello, Does this problem still exist? I've also encountered

houxd1992 avatar Apr 10 '23 10:04 houxd1992