From d7f501c49d523cda423a3ab8bcaeb59a0216b350 Mon Sep 17 00:00:00 2001 From: menduz Date: Thu, 11 Aug 2022 19:31:22 -0300 Subject: [PATCH] fix: extensions broke oneof (#1789) --- src/namespace.js | 5 +++-- tests/api_oneof.js | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/namespace.js b/src/namespace.js index de9f4cdb0..0f0ba6306 100644 --- a/src/namespace.js +++ b/src/namespace.js @@ -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, @@ -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) diff --git a/tests/api_oneof.js b/tests/api_oneof.js index 25fd69c2d..507efc7ab 100644 --- a/tests/api_oneof.js +++ b/tests/api_oneof.js @@ -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;\