protobuf.js version: <6.5.0>
In the generated Static Module code, complex oneof components are initialized to null, but the discriminator getter function checks against undefined
syntax = "proto3";
package test;
message SomeContent {
string someString = 1;
}
message SomeOtherContent {
uint32 someInt = 1;
string someString = 2;
}
message TestMessage {
string someId = 1;
oneof oneOrTheOther {
SomeContent someContent = 2;
SomeOtherContent someOtherContent = 3;
}
}
The create for TestMessage shows
test.TestMessage = (function() {
/**
* Constructs a new TestMessage.
* @exports test.TestMessage
* @constructor
* @param {Object} [properties] Properties to set
*/
function TestMessage(properties) {
if (properties) {
var keys = Object.keys(properties);
for (var i = 0; i < keys.length; ++i)
this[keys[i]] = properties[keys[i]];
}
}
/** @alias test.TestMessage.prototype */
var $prototype = TestMessage.prototype;
/**
* TestMessage someId.
* @type {string}
*/
$prototype.someId = "";
/**
* TestMessage someContent.
* @type {test.SomeContent}
*/
$prototype.someContent = null;
/**
* TestMessage someOtherContent.
* @type {test.SomeOtherContent}
*/
$prototype.someOtherContent = null;
and when encode does a switch on message.oneOrTheOther
it triggers this
Object.defineProperty($prototype, "oneOrTheOther", {
get: function() {
if (this["someContent"] !== undefined)
return "someContent";
if (this["someOtherContent"] !== undefined)
return "someOtherContent";
return undefined;
},
<please paste the stack trace of the error if applicable>
protobuf.js version: <6.5.0>
In the generated Static Module code, complex oneof components are initialized to null, but the discriminator getter function checks against undefined
The create for TestMessage shows
and when encode does a switch on message.oneOrTheOther
it triggers this