Skip to content

Commit 27d6087

Browse files
committed
adjust implementation to always return default options
1 parent 99e8a06 commit 27d6087

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

packages/proto-loader/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,13 @@ function createSerializer(cls: Protobuf.Type): Serialize<object> {
249249
};
250250
}
251251

252-
function mapMethodOptions(options: Partial<MethodOptions>[] | undefined): MethodOptions | undefined {
253-
return Array.isArray(options) ?
254-
options.reduce((obj: MethodOptions, item: Partial<MethodOptions>) => ({ ...obj, ...item }), {}) :
255-
undefined;
252+
function mapMethodOptions(options: Partial<MethodOptions>[] | undefined): MethodOptions {
253+
return (options || []).reduce((obj: MethodOptions, item: Partial<MethodOptions>) => ({ ...obj, ...item }),
254+
{
255+
deprecated: false,
256+
idempotency_level: IdempotencyLevel.IDEMPOTENCY_UNKNOWN,
257+
uninterpreted_option: []
258+
});
256259
}
257260

258261
function createMethodDefinition(

packages/proto-loader/test/descriptor_type_test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ describe('Descriptor types', () => {
160160
},
161161
'(google.api.method_signature)': 'bar'
162162
})
163-
assert(service.HelloWithoutOptions.options === undefined)
163+
assert.deepStrictEqual(service.HelloWithoutOptions.options, {
164+
deprecated: false,
165+
idempotency_level: 'IDEMPOTENCY_UNKNOWN',
166+
uninterpreted_option: []
167+
})
164168
})
165169
});

0 commit comments

Comments
 (0)