Fix missing TypeScript return type for `serverStreaming` calls. (#1167)

* Add strongly types to MethodDescriptor constructor
* Adds return type declaration to server streaming call

Co-authored-by: Eryu Xia <eryu@google.com>
This commit is contained in:
Lukas Möller 2021-11-20 00:15:34 +01:00 committed by GitHub
parent 97baed4dbe
commit 6b1d1e97a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -619,7 +619,8 @@ void PrintTypescriptFile(Printer* printer, const FileDescriptor* file,
printer->Indent(); printer->Indent();
printer->Print(vars, printer->Print(vars,
"request: $input_type$,\n" "request: $input_type$,\n"
"metadata?: grpcWeb.Metadata) {\n"); "metadata?: grpcWeb.Metadata): "
"grpcWeb.ClientReadableStream<$output_type$> {\n");
printer->Print(vars, "return this.client_.serverStreaming(\n"); printer->Print(vars, "return this.client_.serverStreaming(\n");
printer->Indent(); printer->Indent();
printer->Print(vars, printer->Print(vars,

View File

@ -70,9 +70,9 @@ declare module "grpc-web" {
export class MethodDescriptor<REQ, RESP> { export class MethodDescriptor<REQ, RESP> {
constructor(name: string, constructor(name: string,
methodType: any, methodType: string,
requestType: any, requestType: new (...args: unknown[]) => REQ,
responseType: any, responseType: new (...args: unknown[]) => RESP,
requestSerializeFn: any, requestSerializeFn: any,
responseDeserializeFn: any); responseDeserializeFn: any);
createRequest(requestMessage: REQ, createRequest(requestMessage: REQ,
@ -83,10 +83,10 @@ declare module "grpc-web" {
status?: Status): UnaryResponse<REQ, RESP>; status?: Status): UnaryResponse<REQ, RESP>;
getName(): string; getName(): string;
getMethodType(): string; getMethodType(): string;
getResponseMessageCtor(): any; getRequestMessageCtor(): new (...args: unknown[]) => REQ;
getRequestMessageCtor(): any; getResponseMessageCtor(): new (...args: unknown[]) => RESP;
getResponseDeserializeFn(): any;
getRequestSerializeFn(): any; getRequestSerializeFn(): any;
getResponseDeserializeFn(): any;
} }
export class Request<REQ, RESP> { export class Request<REQ, RESP> {