question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript Type Check Errors

See original GitHub issue

Some 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:closed
  • Created 5 years ago
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
henriiikcommented, Oct 26, 2018

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. 😃

0reactions
purebluesongcommented, Nov 6, 2018

thx, I have replaced all grpc-web with this grpc-web although 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found