tsd-jsdoc icon indicating copy to clipboard operation
tsd-jsdoc copied to clipboard

Support @event tag

Open thw0rted opened this issue 2 years ago • 0 comments

Looking around StackOverflow and various blog posts, it seems like the event tag might be one of the least-well-understood tags. Right now, as far as I can tell, tsd-jsdoc just ignores it.

I think it's meant to work similarly to a @typedef -- when I declare an event, I'm saying that the owning function / class / namespace will at some point invoke a callback with an object that has certain properties. That sounds a lot like a TypeScript interface.

What I'm suggesting is that tsd-jsdoc treat these as equivalent:

/**
 * @typedef {Object} Foo.BarEvent
 *
 * An Event with an "x" property
 *
 * @property {number} x
 */
/**
 * An Event with an "x" property
 * @event Foo.BarEvent
 *
 * @type {Object}
 * @property {number} x
 */

In both case an interface called BarEvent should be created in the namespace Foo.

thw0rted avatar Apr 15 '22 16:04 thw0rted