WebStorm 6.0.1, JSDoc3, @callback

I'm having trouble getting WebStorm 6.0.1 to properly recognize the @callback tag in my JavaScript JSDocs. Does WebStorm support JSDoc3?

If there answer is "yes" I'll post a follow up question.

Cheers.

3 comments

Wow! That was not the answer I was expecting. I like WebStorm but I would have thought support for the latest JSDoc would be a no-brainer.

Thanks for your reply. I encourage others to vote too.

0

I have managed to use almost everything with the exception of the {{@callback}} annotation (WebStorm 7.0.3). For that one I have used a workaround:

I first document the callback as JSDoc3 would expect, so that it gets generated in the documentation files.

/**
* @desc Callback for all asynchronous functions.
* @callback PurchaseOrder.callback
* @param {number} err - the error status code.
* @param {PurchaseOrder=} order - the raw order data.
*/


Now, since WebStorm still does not recognise this syntax, it will generate warnings if we try to use it as the type of our callback arguments. So, in the actual callback parameter, I simply use closure compiler syntax.

/**
* Finds a purchase order by its id.
*
* @param {number} orderId - the purchase order id.
* @param {function(number,PurchaseOrder=)} callback - the result callback
*/
PurchaseOrder.findPurchaseOrderById = function(orderId, callback){
callback(404);
};


This, at least guarantees that the type is documented as expected by JSDoc3, and satisfies WebStorm for the time being. Later on, when WebStorm supports it, we can simply get rid of the closure compiler syntax and use the callback type instead.

0

Please sign in to leave a comment.