From d0646a66509a01bbcda096e208dc38cdcc743cbd Mon Sep 17 00:00:00 2001 From: John Children Date: Fri, 7 Oct 2016 17:07:44 +0100 Subject: [PATCH 1/2] Correct minor error on ProtoEnum values array The values field of the ProtoEnum interface should be an array not a single entry. This can be seen when using the Protobuf.js parser on enum fields where a file containing: ``` enum Priority { LOW = 1; MEDIUM = 2; HIGH = 3; } ``` Is parsed to: ``` { package: null, messages: [], enums: [ { name: 'Priority', values: [ { name: 'LOW', id: 1 }, { name: 'MEDIUM', id: 2 }, { name: 'HIGH', id: 3 } ], options: {} } ], imports: [], options: {}, services: [] } ``` --- protobufjs/protobufjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobufjs/protobufjs.d.ts b/protobufjs/protobufjs.d.ts index fac34be103..139a9b94c8 100644 --- a/protobufjs/protobufjs.d.ts +++ b/protobufjs/protobufjs.d.ts @@ -224,7 +224,7 @@ declare namespace ProtoBuf { export interface ProtoEnum { name: string; - values: ProtoEnumValue; + values: ProtoEnumValue[]; options: {[key: string]: any}; } From 45e67bac511ce88877b9c0381796b376290de96a Mon Sep 17 00:00:00 2001 From: John Children Date: Fri, 7 Oct 2016 17:24:29 +0100 Subject: [PATCH 2/2] Update protobufjs-tests.ts --- protobufjs/protobufjs-tests.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/protobufjs/protobufjs-tests.ts b/protobufjs/protobufjs-tests.ts index fd29685f15..bec806ee0c 100644 --- a/protobufjs/protobufjs-tests.ts +++ b/protobufjs/protobufjs-tests.ts @@ -180,7 +180,9 @@ function assertIsProtoEnum(pe: ProtoBuf.ProtoEnum, name: string) { assert.ok("values" in pe, name + " should contain property values"); assert.ok("options" in pe, name + " should contain property options"); - assertIsProtoEnumValue(pe.values, name + ".values"); + for (var value in pe.values) { + assertIsProtoEnumValue(pe.values[value], name + ".values." + value); + } } function assertIsProtoEnumValue(pev: ProtoBuf.ProtoEnumValue, name: string) {