Skip to main content

@constructs

Syntax

@constructs
@constructs ClassName

Overview

@constructs is used when an object literal returned by a factory function or a @lends block acts as the constructor for a class. It tells JSDoc that the containing function definition creates instances of the named class.

Example

/**
* @constructs MyClass
*/
function MyClass() {
this.value = 0;
}

With @lends

A common pattern is to use @lends together with @constructs when creating classes via object literals:

var MyClass = (function () {
/**
* @lends MyClass.prototype
*/
function MyClass() {
/** @constructs */
}

MyClass.prototype.greet = function () {
return 'Hello!';
};

return MyClass;
})();

See also

Official reference: jsdoc.app/tags-constructs