Skip to content

MethodDescriptor type issue in TypeScript #1351

Open
@danias

Description

@danias

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

The autogenerated files are not compatible with the current MethodDescriptor definition that has ...args: unknown[]. As a result my TypeScript project fails to run.

Argument of type 'typeof MyRequest' is not assignable to parameter of type 'new (...args: unknown[]) => MyRequest'.

The command I am running to generate the files is the following:

"proto": "protoc -I=. src/proto/proto.proto --ts_out=. --ts_opt=target=web,json_names,unary_rpc_promise=true,no_namespace --grpc-web_out=import_style=typescript,mode=grpcwebtext:.",

Here is the diff that solved my problem:

diff --git a/node_modules/grpc-web/index.d.ts b/node_modules/grpc-web/index.d.ts
index 09fb671..9b6b233 100644
--- a/node_modules/grpc-web/index.d.ts
+++ b/node_modules/grpc-web/index.d.ts
@@ -71,8 +71,8 @@ declare module "grpc-web" {
   export class MethodDescriptor<REQ, RESP> {
     constructor(name: string,
                 methodType: string,
-                requestType: new (...args: unknown[]) => REQ,
-                responseType: new (...args: unknown[]) => RESP,
+                requestType: new (...args: any) => REQ,
+                responseType: new (...args: any) => RESP,
                 requestSerializeFn: any,
                 responseDeserializeFn: any);
     getName(): string;

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions