Search code examples
javascriptdocumentationjsdoc

JSDoc 3 Document constructor/class parameter


How can I document a constructor (function) passed as a parameter?

Example:

/** @class */
function A() {}

/**
 * @param {Function} aConstructor
 */
function createA(aClass) {
    return new aClass();
}

As you can see, I can specify that it is a function. However, I can't specify which object that function would create. Is there some way to document this?

Thanks.


Solution

  • As discussed in the comments, I'd file a request because it doesn't appear to me to support that capability. Using the approach of instanceof, "Function" is the closest in representing the object instance for a constructor for the time being. As mentioned, @constructs or @returns may be able to help you to indicate the output, but not the parameter input.