`Cannot access '...' before initialization` when a map type is defined in .proto file
antonioorct opened this issue · comments
Uncaught ReferenceError: Cannot access 'TestResponse' before initialization
at Module../src/test.pb.ts (test.pb.ts:84)
at Module.options.factory (react refresh:6)
at __webpack_require__ (bootstrap:24)
at fn (hot module replacement:61)
at Module../src/App.tsx (logo.svg:34)
at Module.options.factory (react refresh:6)
at __webpack_require__ (bootstrap:24)
at fn (hot module replacement:61)
at Module../src/index.tsx (App.tsx:30)
at Module.options.factory (react refresh:6)
I've encountered this error in my React app when i defined a map of any two types in a .proto file.
E.g.
message Foo {
map<string, int32> Bar = 1;
}
I've created a repo with the error recreated: https://github.com/antonioorct/twirpscript-initialization-error
Hey @antonioorct I haven't implemented map
for TwirpScript but I'm happy to do so -- it's the one data type (other than Group
which is not usable in protobuf3
) that has yet to be implemented.
I need to look into map backwards compatibility https://developers.google.com/protocol-buffers/docs/proto3#backwards_compatibility for the implementation.
A little delay here, AFAICT google's protobuf library does not expose the map type. I'll look for a workaround in the meantime.
@antonioorct I've added support for the map
type in v0.0.36.