Skip to content

Commit ce8aa02

Browse files
authored
Fix response return type for grpcwebclientbase_test (#1433)
1 parent e91e540 commit ce8aa02

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

javascript/net/grpc/web/grpcwebclientbase_test.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ testSuite({
118118
xhr.simulateReadyStateChange(ReadyState.COMPLETE);
119119
const response = await responsePromise;
120120

121-
assertEquals('value', response.data);
121+
assertEquals('value', /** @type {!MockReply} */ (response).data);
122122
const headers = /** @type {!Object} */ (xhr.getLastRequestHeaders());
123123
assertElementsEquals(DEFAULT_UNARY_HEADERS, Object.keys(headers));
124124
assertElementsEquals(DEFAULT_UNARY_HEADER_VALUES, Object.values(headers));
@@ -294,8 +294,18 @@ class MockReply {
294294
}
295295

296296
/**
297-
* @param {function(string): !MockReply} responseDeSerializeFn
298-
* @return {!MethodDescriptor<!MockRequest, !MockReply>}
297+
* Typedef for allowed response types.
298+
*
299+
* Number is allowed specifically for supporting falsy responses `0`, see:
300+
* https://github.com/grpc/grpc-web/pull/1025
301+
*
302+
* @typedef {!MockReply|number}
303+
*/
304+
let AllowedResponseType;
305+
306+
/**
307+
* @param {function(string): !AllowedResponseType} responseDeSerializeFn
308+
* @return {!MethodDescriptor<!MockRequest, !AllowedResponseType>}
299309
*/
300310
function createMethodDescriptor(responseDeSerializeFn) {
301311
return new MethodDescriptor(

0 commit comments

Comments
 (0)