diff --git a/index.ts b/index.ts index 9f37329..cfb0fbc 100644 --- a/index.ts +++ b/index.ts @@ -205,7 +205,7 @@ export const list = { * @param {ListValue} list the protobuf list value. * @returns {Array.<*>} */ - decode({values}: ListValue): JsonArray { + decode({values = []}: ListValue): JsonArray { return values.map(value.decode); } }; diff --git a/test.ts b/test.ts index 774d502..9f215e3 100644 --- a/test.ts +++ b/test.ts @@ -219,3 +219,8 @@ test('struct.decode - undefined fields', t => { const actual = struct.decode({}); t.deepEqual(actual, {}); }); + +test('struct.decode - empty listValue', t => { + const actual = struct.decode({ fields: { test: { listValue: {} } } }); + t.deepEqual(actual, {test: []}); +});