amqp-client.js icon indicating copy to clipboard operation
amqp-client.js copied to clipboard

Sonarlint throwing a TypeError warning for AMQPConsumer / q.subscribe using example on README

Open JoshJarabek7 opened this issue 2 years ago • 2 comments

AMQPConsumer / await q.subscribe callback is set to return a type <void>, however, the example on the README is a Promise<void>

This part:

    const consumer = await q.subscribe({noAck: true}, async (msg) => {
      console.log(msg.bodyToString())
      await consumer.cancel()
    })

Warning:

Promise returned in function argument where a void return was expected.sonarlint(typescript:S6544)
(parameter) msg: AMQPMessage

Dropping the async in front of message gets rid of the squiggles:

const consumer = await queue.subscribe({ noAck: true }, (msg: AMQPMessage) => {
	const message = msg.bodyToString()
	console.log(message)
})

Should probably be <void> | Promise<void>

JoshJarabek7 avatar Sep 27 '23 20:09 JoshJarabek7

I take it README needs an update? A pull request would be welcomed :)

dentarg avatar Sep 27 '23 20:09 dentarg

@dentarg sounds good. I've never done one before though. The README is probably fine, the method's expected return just needs to include a Promise response as well.

JoshJarabek7 avatar Sep 27 '23 20:09 JoshJarabek7