0

I have the following code:

type AlarmEvent = events.Event<(name: Alarm) => void>;

As you can see, the event class takes a generic parameter in the form of a function signature, which I'd like to document.

Any ideas?

Lusito
  • 933
  • 8
  • 10

1 Answers1

1

If all you need is a place to hang normal JSDocs off of, you can just create another type:

type AlarmHandler = (name: Alarm) => void
type AlarmEvent = events.Event<AlarmHandler>

If you need this to work with JSDoc you can use the @callback tag in a standalone JSDoc comment to do the work:

/**
 * Handles alarm events
 * @callback
 * @param {Alarm} name The alarm that fired
*/
Sean Vieira
  • 155,703
  • 32
  • 311
  • 293