Argument of type 'Handler' is not assignable to parameter of type 'UntypedServiceImplementation' - grpc_tools_node_protoc_ts

Upgraded to the latest and started getting the error message above when using the addService call. Noticed that in your example you are ignoring the compilation issue with the ts-ignore directive, is this a known issue?

https://github.com/agreatfool/grpctoolsnodeprotocts/blob/b85f1440a357a2f4a935d14dfd78072a7dcbfb10/examples/src/grpcjs/server.ts#L75

Asked Sep 29 '21 04:09
avatar yellowandy
yellowandy

6 Answer:

Do you mean this one? https://github.com/agreatfool/grpctoolsnodeprotocts/issues/60

1
Answered Dec 18 '20 at 01:48
avatar  of agreatfool
agreatfool

Seems not, could you share some sample codes or proto file? Also the versions you are using. Including the grpc_tools_node_protoc.

1
Answered Dec 18 '20 at 01:49
avatar  of agreatfool
agreatfool

Yes, it's a known issue. Let me have a look what I can do to solve | improve it.

1
Answered Dec 18 '20 at 02:08
avatar  of agreatfool
agreatfool

Thanks. Great to see this fixed. It looks like we now have Type parity across the popular tools:

  • grpc-proto-loader
  • ts-protoc-gen
  • grpctoolsnodeprotocts

I'll update my example in https://github.com/badsyntax/grpc-js-types/tree/master/examples/grpctoolsnodeprotocts#issues-with-this-approach to show this latest change.

1
Answered Dec 29 '20 at 12:17
avatar  of badsyntax
badsyntax

I'm not sure this is fixed. After updating to 5.1.0, I started getting TS compilation errors due to this change. VS Code expects the following to be in my implementation:

class MyServerImpl implements IMyServiceServer {
    [name: string]: grpc.UntypedHandleCall; // <== This line is expected...

    // But if I have properties / methods that are not RPC-handling like...
    data: Foo = ...;
    someOtherFunction() {...}
}

I get the following compiler error: Property 'data' of type 'Foo' is not assignable to string index type 'HandleCall'.ts(2411)

1
Answered Jan 04 '21 at 07:17
avatar  of codedread
codedread