You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the generated typescript definition file, the callback argument of service methods is defined as () => any. It makes it impossible to call the method with arguments.
The correct definition should be (err: Error | null, response?: <response_type>) => void (perfect) or Function (if too difficult to manage with tsd-jsdoc).
The same error applies for the rpc argument of the service's constructor that should be (method: Method, requestData: Uint8Array, callback: (err: Error | null, responseData?: Uint8Array) => void) => void (best) or (method: Function, requestData: Uint8Array, callback: Function) => void or Function.
declare module "greeter" {
// ...
/**
* Constructs a new Greeter.
* @exports Greeter
* @constructor
* @param {function(function, Uint8Array, function)} rpc RPC implementation
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited
*/
class Greeter {
/**
* Constructs a new Greeter.
* @exports Greeter
* @constructor
* @param {function(function, Uint8Array, function)} rpc RPC implementation
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited
*/
constructor(rpc: () => any, requestDelimited?: boolean, responseDelimited?: boolean);
/**
* RPC implementation.
* @type {function(function, Uint8Array, function)}
*/
rpc: () => any;
/**
* Whether requests are length-delimited.
* @type {boolean}
*/
requestDelimited: boolean;
/**
* Whether responses are length-delimited.
* @type {boolean}
*/
responseDelimited: boolean;
/**
* Calls SayHello.
* @param {HelloRequest|Object} request HelloRequest or plain object
* @param {function(?Error, HelloReply=)} callback Node-style callback called with the error, if any, and HelloReply
* @returns {undefined}
*/
["sayHello"](request: (HelloRequest|Object), callback: () => any): void;
}
}
If I call sayHello(new HelloRequest(), (err, response) => {}), I get an error stating (err, response) => void is not assignable to () => any. If I call sayHello(..., () => {}), I cannot process the error or the response since no variable defines them.
The text was updated successfully, but these errors were encountered:
protobuf.js version: master
In the generated typescript definition file, the
callback
argument of service methods is defined as() => any
. It makes it impossible to call the method with arguments.The correct definition should be
(err: Error | null, response?: <response_type>) => void
(perfect) orFunction
(if too difficult to manage with tsd-jsdoc).The same error applies for the
rpc
argument of the service's constructor that should be(method: Method, requestData: Uint8Array, callback: (err: Error | null, responseData?: Uint8Array) => void) => void
(best) or(method: Function, requestData: Uint8Array, callback: Function) => void
orFunction
.With the greeter example:
we get:
If I call
sayHello(new HelloRequest(), (err, response) => {})
, I get an error stating(err, response) => void
is not assignable to() => any
. If I callsayHello(..., () => {})
, I cannot process the error or the response since no variable defines them.The text was updated successfully, but these errors were encountered: