-
Notifications
You must be signed in to change notification settings - Fork 399
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
Drop next() as a function parameter type on listeners #1457
Comments
@M1kep - The error message you are seeing is expected. There is a way to define a listener middleware. Here is thedocumentation for that and the way to use |
That I'd need to look further into. Thanks for clarifying, I'll take a look at what's going on with the type definition there... |
I've tweaked the title and labels in this issue to have this issue focus on improving the types in this situation. |
I've taken a look at this issue a bit more. I would summarize the issue like this:
I think the easy fix here is to provide a no-op @M1kep what did you expect to happen when you called // Log action_ids of all actions when in Debug mode
bot.appInstance?.action(/.*/, async ({ action, logger, next }) => {
if ('action_id' in action) {
logger.debug(`Action Hit(${botName}): ${action.action_id}`);
}
await next();
}); Not questioning or judging, just trying to make sure I understand what a developer's expectations are. Thanks for any info! I the mean time, I will try my hand at PR to capture the problem in a test and see if my proposed fix could work to address this. |
Hey @filmaj, It's been a bit since I was working on this, and have been away from TS for a bit so am little rusty.. If I recall correctly, I think this was mostly a case of the type hints leading to some confusion. When I saw that the action middleware/listener accepted next(), I'd assumed it should be called. Ideally, the type signature wouldn't provide next at all, but I'm not sure that's a realistic expectation for the type system. I think a no-op next() would completely solve the issue in a non-breaking manner, possibly with a dev time warning statement? |
Description
Describe your issue here.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version: 3.11.0
node version: 16.15.0
OS version(s): Docker - node:16-alpine
Steps to reproduce:
Expected result:
Either TypeScript does not provide next as a valid parameter, or next to exist.
Actual result:
Error:
Attachments:
Logs, screenshots, screencast, sample project, funny gif, etc.
The text was updated successfully, but these errors were encountered: