How to define a function as an implementation of a callback in JSDoc?

I defined a @callback as follows:

 /** * @callback MyClass~Handler * @param {string} target * @param {Options} options - Original options */ 

I use it to define the prototype of my class:

 /** * @param {string} name - The name * @param {MyClass~Handler} handler * @private */ MyClass.prototype._builder = function(name, handler) { //... 

But how to tell JSDoc that the following function has the same definition as my MyClass~Handler (something like @isacallback in the following code)?

 /** * Default handler * @isacallback {MyClass-Handler} * @private */ MyClass.prototype._defaultHandler = function(target, options) { // ... 
+5
source share
1 answer

I have not tested this, but since @callback just defines the type, could you use the @type ?

In other words:

 /** * Default handler * @type {MyClass-Handler} * @private */ MyClass.prototype._defaultHandler = function(target, options) { // ... 

For more on @type see http://usejsdoc.org/tags-type.html .

0
source

Source: https://habr.com/ru/post/1202082/


All Articles