Skip to content

Commit d7f501c

Browse files
authored
fix: extensions broke oneof (#1789)
1 parent 6f0806d commit d7f501c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/namespace.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ var ReflectionObject = require("./object");
66
((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace";
77

88
var Field = require("./field"),
9-
util = require("./util");
9+
util = require("./util"),
10+
OneOf = require("./oneof");
1011

1112
var Type, // cyclic
1213
Service,
@@ -217,7 +218,7 @@ Namespace.prototype.getEnum = function getEnum(name) {
217218
*/
218219
Namespace.prototype.add = function add(object) {
219220

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

223224
if (!this.nested)

tests/api_oneof.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ var def = {
88
};
99

1010
var proto = "syntax = \"proto3\";\
11+
import \"google/protobuf/descriptor.proto\";\
12+
extend google.protobuf.FileOptions { optional int32 ecs_component_id = 50000;}\
13+
option (ecs_component_id) = 1020;\
1114
message Test {\
1215
oneof kind {\
1316
uint32 a = 1;\

0 commit comments

Comments
 (0)