Search code examples
javascriptparametersdocumentationjsdoc

JSDoc - Document Object of type


In JSDoc, how does one document an Object of certain defined type?

For example, if I have a function which receives a HTMLImageElement object, how should I document it in the parameters?

Would it be like just like this @param {HTMLImageElement} - An image or @param {Object<HTMLImageElement>} ?


Solution

  • The first option you mentioned is correct:

    @param {HTMLImageElement} An image
    

    All class/object types can be used as a type in the type parameter. You don't need to do anything fancy with them.

    And since all class instances are objects, you know it is also an object.