@callback
Syntax
@callback CallbackName
Overview
@callback defines a named function type (a callback signature) that can be referenced from @param and @type. It works like @typedef but is specifically designed for function types. After defining the callback, use @param and @returns within the same block to describe the callback's parameters and return value.
Example
/**
* @callback RequestCallback
* @param {Error|null} err - An error, or null on success.
* @param {Object} response - The response data.
*/
/**
* Sends a network request.
* @param {string} url - The endpoint URL.
* @param {RequestCallback} callback - Called when the request completes.
*/
function request(url, callback) {}
Namespaced callback
Attach the callback to a module or namespace to avoid name collisions:
/**
* @callback module:net~RequestCallback
* @param {Error|null} err
* @param {Object} data
*/
See also
Official reference: jsdoc.app/tags-callback