node-rdkafka icon indicating copy to clipboard operation
node-rdkafka copied to clipboard

consume callback has an incorrect typing

Open abarisain opened this issue 2 years ago • 1 comments

Environment Information

  • node-rdkafka version [e.g. 2.3.3]: 2.18.0

Steps to Reproduce

Use .consume(callback) from typescript. Type of "messages" in the callback is Message[] while the lib returns a single message. I have to force cast it to use it:

consumer.consume((err, msg) => {
  const message = msg as unknown as RDKafka.Message;

The .consume variant with two parameters is alright

abarisain avatar Nov 15 '23 13:11 abarisain

writeRegisters [1] and read[..]Registers method allow you to write and read the buffer, when writing and reading you can set the buffer using the encoding you need, see a read example [2][3].

[1] https://github.com/yaacov/node-modbus-serial/blob/master/ModbusRTU.d.ts#L60 [2] https://github.com/yaacov/node-modbus-serial/blob/master/ModbusRTU.d.ts#L77 [3] https://github.com/yaacov/node-modbus-serial/blob/master/examples/buffer.js#L28

yaacov avatar Nov 30 '22 04:11 yaacov