@interface
Syntax
@interface
@interface name
Overview
@interface marks a symbol as an interface — a contract that other classes can @implements. An interface defines method and property signatures without providing an implementation.
Example
/**
* @interface
*/
function Serializable() {}
/**
* Serialize the object to a JSON string.
* @returns {string}
*/
Serializable.prototype.toJSON = function () {};
/**
* Restore the object from a JSON string.
* @param {string} json
*/
Serializable.prototype.fromJSON = function (json) {};
Implementing an interface
/**
* @implements {Serializable}
*/
class User {
toJSON() { return JSON.stringify(this); }
fromJSON(json) { Object.assign(this, JSON.parse(json)); }
}
See also
Official reference: jsdoc.app/tags-interface