Fix response return type for grpcwebclientbase_test (#1433)

This commit is contained in:
Eryu Xia 2024-06-12 11:01:19 -07:00 committed by GitHub
parent e91e540fc2
commit ce8aa02c7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 3 deletions

View File

@ -118,7 +118,7 @@ testSuite({
xhr.simulateReadyStateChange(ReadyState.COMPLETE);
const response = await responsePromise;
assertEquals('value', response.data);
assertEquals('value', /** @type {!MockReply} */ (response).data);
const headers = /** @type {!Object} */ (xhr.getLastRequestHeaders());
assertElementsEquals(DEFAULT_UNARY_HEADERS, Object.keys(headers));
assertElementsEquals(DEFAULT_UNARY_HEADER_VALUES, Object.values(headers));
@ -294,8 +294,18 @@ class MockReply {
}
/**
* @param {function(string): !MockReply} responseDeSerializeFn
* @return {!MethodDescriptor<!MockRequest, !MockReply>}
* Typedef for allowed response types.
*
* Number is allowed specifically for supporting falsy responses `0`, see:
* https://github.com/grpc/grpc-web/pull/1025
*
* @typedef {!MockReply|number}
*/
let AllowedResponseType;
/**
* @param {function(string): !AllowedResponseType} responseDeSerializeFn
* @return {!MethodDescriptor<!MockRequest, !AllowedResponseType>}
*/
function createMethodDescriptor(responseDeSerializeFn) {
return new MethodDescriptor(