How to return void in JsDoc? How to return void in JsDoc? javascript javascript

How to return void in JsDoc?


Closure Compiler

According to the documentation of Google's Closure Compiler if nothing is being returned, the @return annotation should be omitted.

If there is no return value, do not use a @return tag.

Source: https://developers.google.com/closure/compiler/docs/js-for-compiler#tags

jsdoc-toolkit

However further documentation also states that the returnType and returnDescription are optional parameters.

returnType - Optional: the type of the return value.

returnDescription - Optional: any additional description.

Source: https://code.google.com/p/jsdoc-toolkit/wiki/TagReturns

Summary

You could either leave out the return annotation or include it without any parameters.


I don't believe you have to choose from a set of types in JsDoc... you can use any type name you wish (the curly braces indicate it's a type), so you can simply do:

@return {Void}

Although, this is probably more correct for JavaScript:

@return {undefined}


Looking at the ESlint docs they use@returns {void}

Source: http://eslint.org/docs/rules/valid-jsdoc

Since I need to provide an @returns for each function to pass tests in order to push code for certain projects this is required in my case.