Skip to content

Enum Translations #60

@dsshap

Description

@dsshap

I have a very simple enum, and when i decode a message the enum is the value rather than the key.

Is this on purpose? My initial thinking was that the enum gets translated to value, communicated, then translated back to the key when a message is decoded.

enum Carrier {
  T_MOBILE = 0;
  ATT = 1;
}
message Test {
  Carrier carrier = 1;
}
var buf = messages.Test.encode({
  carrier: messages.Carrier.ATT
});
var obj = messages.Test.decode(buf)
console.log(obj)
>>  { carrier: 1 }

Expected (something like this):

var obj = messages.Test.decode(buf)
console.log(obj)
>>  { carrier: 'ATT' } 

I can get the key with additional step using lodash, but like i mentioned above, that feels contrary to what i was expecting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions