What is the correct way to document EventEmitters?

Viewed 91

I am trying to document an EventEmitter, but the documentation isn't very clear about what should be done, and every information I could find when searching for help or examples is even more confusing.

My final goal is to have a class that has a on method, that can listen to multiple events, all of which having a different callback. For example, if I have a messageEvent event, that takes a single String as parameter in its callback, I would like my IDE (in my case VSCode) to tell me, when I listen to a messageEvent, that the callback for it takes a String, and not an unknown number of any type.

I know this is possible with JSDoc, as I already worked with npm packages that documents them well (e.g. discord.js), but every time I try something different from what I already tried, I get even more confused.

What I already know is that I have to use @event, @fires and @listens tags, but I understand neither how nor where.

Could someone explains to me what I am supposed to do, possibly with examples? I would be very grateful.

0 Answers
Related