Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with protobufjs 6.7.x #7

Closed
JustGreg opened this issue Apr 10, 2017 · 11 comments
Closed

Not compatible with protobufjs 6.7.x #7

JustGreg opened this issue Apr 10, 2017 · 11 comments
Assignees
Labels

Comments

@JustGreg
Copy link

the rxjs-grpc cli produce this line:

sayHello(request: (sample.HelloRequest|{ [k: string]: any })): Observable<sample.HelloReply>;

You will get the error Property 'name' does not exist on type 'HelloRequest | { [k: string]: any; }'.
If you change the pipe-symbol | to an ampersand-symbol & it should work.

sayHello(request: (sample.HelloRequest & { [k: string]: any })): Observable<sample.HelloReply>;
@kondi
Copy link
Owner

kondi commented Apr 10, 2017

Could you share your yarn lock file? Or if not used, the package json?

@JustGreg
Copy link
Author

yarn.lock
yarn.txt

@kondi
Copy link
Owner

kondi commented Apr 10, 2017

Quick fix: revert back protobufjs to ~6.6.5.
Looks like it is not compatible currently with 6.7.x, I will look at it later.

kondi added a commit that referenced this issue Apr 10, 2017
kondi added a commit that referenced this issue Apr 10, 2017
@kondi kondi changed the title "request" definition not working Not compatible with protobufjs 6.7.x Apr 10, 2017
@kondi
Copy link
Owner

kondi commented Apr 10, 2017

You can update rxjs-grpc to 0.1.2, it has set the correct protobufjs version.

@kondi kondi added the bug label Apr 10, 2017
@kondi kondi self-assigned this Apr 10, 2017
@JustGreg
Copy link
Author

thank you, it works!

atom and vs code still show the error Property 'xyz' does not exist... with Typescript 2.2.1 and 2.2.2

@kondi
Copy link
Owner

kondi commented Apr 10, 2017

It should work well in VS code, I am using it everyday. Can you share a bit more? At least the ts file and on which line you have the error.

@JustGreg
Copy link
Author

sample.proto

syntax = "proto3";

package sample;

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {}
  rpc SayMultiHello (MultiHelloRequest) returns (stream HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The request message containing the user's name and how many greetings they want.
message MultiHelloRequest {
  string name = 1;
  required uint32 num_greetings = 2;
}

// The response message containing the greetings.
message HelloReply {
  string message = 1; 
}

server.ts

import { Observable } from 'rxjs';
import { serverBuilder } from 'rxjs-grpc';
import { sample } from './grpc-namespaces';

async function main() {
  type ServerBuilder = sample.ServerBuilder;
  const server = serverBuilder<ServerBuilder>('sample.proto', 'sample');

  server.addGreeter({

    sayHello(request) {
      return Observable.of({
        message: 'Hello ' + request.name
      });
    },

    sayMultiHello(request) {
      return Observable.timer(100, 500)
        .mapTo({ message: `Hello ${request.name}` })
        .take(request.num_greetings);
    }

  });

  server.start('0.0.0.0:50051');
}

main().catch(error => console.error(error));

client.ts

import { clientFactory } from 'rxjs-grpc';
import { sample } from './grpc-namespaces';

async function main() {
  type ClientFactory = sample.ClientFactory;
  const Services = clientFactory<ClientFactory>('sample.proto', 'sample');

  const services = new Services('localhost:50051');
  const greeter = services.getGreeter();

  await greeter.sayMultiHello({ name: 'world', num_greetings: 3 }).forEach(response => {
    console.log(`Multi greeting: ${response.message}`);
  });

  await greeter.sayHello({ name: 'world' }).forEach(response => {
    console.log(`Greeting: ${response.message}`);
  });

}

main().catch(error => console.error(error));

server ts

@JustGreg
Copy link
Author

yarn.lock

@kondi
Copy link
Owner

kondi commented Apr 10, 2017

It looks like the grpc-namespaces is still the one generated with the old version.

@JustGreg
Copy link
Author

you are right! i recreated the namespace-file and now everythink looks good

@kondi kondi added this to the 1.0-rc.0 milestone Jun 8, 2018
@kondi kondi closed this as completed in 15bd7f7 Mar 4, 2019
@kondi kondi removed this from the 1.0-rc.0 milestone Mar 5, 2019
@kondi
Copy link
Owner

kondi commented Mar 5, 2019

Released in v0.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants