Skip to content

Commit

Permalink
fix: extensions broke oneof (protobufjs#1789)
Browse files Browse the repository at this point in the history
  • Loading branch information
menduz authored Aug 11, 2022
1 parent 6f0806d commit d7f501c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var ReflectionObject = require("./object");
((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace";

var Field = require("./field"),
util = require("./util");
util = require("./util"),
OneOf = require("./oneof");

var Type, // cyclic
Service,
Expand Down Expand Up @@ -217,7 +218,7 @@ Namespace.prototype.getEnum = function getEnum(name) {
*/
Namespace.prototype.add = function add(object) {

if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof Enum || object instanceof Service || object instanceof Namespace))
if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof OneOf || object instanceof Enum || object instanceof Service || object instanceof Namespace))
throw TypeError("object must be a valid nested object");

if (!this.nested)
Expand Down
3 changes: 3 additions & 0 deletions tests/api_oneof.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ var def = {
};

var proto = "syntax = \"proto3\";\
import \"google/protobuf/descriptor.proto\";\
extend google.protobuf.FileOptions { optional int32 ecs_component_id = 50000;}\
option (ecs_component_id) = 1020;\
message Test {\
oneof kind {\
uint32 a = 1;\
Expand Down

0 comments on commit d7f501c

Please sign in to comment.