Skip to content

Enums are not handled in the proto compiler #34

@evanw

Description

@evanw

Maybe I'm missing something, but I can't get enums to work:

$ cat > example.proto
package figma;

enum ExampleType {
  A = 0;
  B = 1;
}

message Example {
  required ExampleType type = 1;
}
$ ./bin/pbf example.proto > example.js
$ node -e 'pbf = require("./index"), console.log(require("./example").Example.write({type: "A"}, new pbf()))'
pbf/example.js:16
    if (example.type !== undefined) pbf.writeMessage(1, writeExampleType, exam
                                                        ^
ReferenceError: writeExampleType is not defined
    at Object.writeExample [as write] (pbf/example.js:16:57)
    at [eval]:1:68
    at Object.exports.runInThisContext (vm.js:74:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:460:26)
    at evalScript (node.js:431:25)
    at startup (node.js:90:7)
    at node.js:814:3

It looks like there's code that should be handling enums, it's just never being called.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions