Typescript Type Check Errors
See original GitHub issueSome errors exposed when I try to compile my generated typescript code.
One error message here:
Argument of type '(request: Empty) => Uint8Array' is not assignable to parameter of type '(request: {}) => {}'.
Types of parameters 'request' and 'request' are incompatible.
Type '{}' is not assignable to type 'Empty'.
Property 'serializeBinary' is missing in type '{}'.
And I found the generation code is here: https://github.com/grpc/grpc-web/blob/86631990e365130d5cfca3aa93613ec1eeef7da4/javascript/net/grpc/web/grpc_generator.cc#L395
Another error message here:
Argument of type '(err: Error, response: Empty) => void' is not assignable to parameter of type '(err: Error, response: {}) => void'.
Types of parameters 'response' and 'response' are incompatible.
Type '{}' is not assignable to type 'Empty'.
And I found the generation code is here: https://github.com/grpc/grpc-web/blob/86631990e365130d5cfca3aa93613ec1eeef7da4/javascript/net/grpc/web/grpc_generator.cc#L438
The part of the wrong generated code shows here:
methodInfoSome = new grpcWeb.AbstractClientBase.MethodInfo(
Empty,
(request: SomeRequest) => { // Here is the first error
return request.serializeBinary();
},
Empty.deserializeBinary
);
some(
request: SomeRequest,
metadata: grpcWeb.Metadata,
callback: (err: grpcWeb.Error,
response: Empty) => void) {
return this.client_.rpcCall(
this.hostname_ +
'/SomePath',
request,
metadata,
this.methodInfoSome,
callback); // Here is the second error which the callback is `(err: Error, response: Empty) `
}
The Empty
message defined in proto file likes this message Empty {}
FYI: My TS version is 3.0.1
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (3 by maintainers)
Top Results From Across the Web
Improving TypeScript error handling with exhaustive type ...
Discover an improved method for handling errors in TypeScript that solves problems that arise from returning null and throwing try...catch.
Read more >How to check TypeScript code for syntax errors from a ...
I have looked at TypeScript compiler options but see no such option. How can I check the syntax? I don't want a full...
Read more >Documentation - Understanding Errors
TypeScript found an error when checking the last line. Its logic for issuing an error follows from its logic for determining if the...
Read more >Get a catch block error message with TypeScript
TypeScript forces you to acknowledge you can't know what was thrown making getting the error message a pain. Here's how you can manage...
Read more >Type-Safe Error Handling In TypeScript
In this post, I introduce the concept of a Result type, which eliminates the need for throwing exceptions, and reduces risk of runtime ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I ran into this as well, and i think it is related to typescripts strict mode.
If you are interested i can probably come up with a fix and send a PR. 😃
thx, I have replaced all grpc-web with this grpc-web although 😃