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

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

Open
JoshJarabek7 opened this issue Sep 27, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed

Comments

@JoshJarabek7
Copy link

JoshJarabek7 commented Sep 27, 2023

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>

@dentarg dentarg added documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed labels Sep 27, 2023
@dentarg
Copy link
Member

dentarg commented Sep 27, 2023

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

@JoshJarabek7
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants