Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSDoc 3 Document constructor/class parameter

How can I document a constructor (function) passed as a parameter?

Example:

/** @class */
function A() {}

/**
 * @param {Function} aConstructor
 */
function createA(aClass) {
    return new aClass();
}

As you can see, I can specify that it is a function. However, I can't specify which object that function would create. Is there some way to document this?

Thanks.

like image 669
samanime Avatar asked Jun 16 '13 01:06

samanime


1 Answers

Google with its closure propose a {function(new:type)} as a type description. I've assumed, that one can use something like this (I'm using it with AMD):

 /** @param {function(new:ClassOrInterfaceName)} aClass */

You can find more information here: http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml#JavaScript_Types

I hope, my answer can help someone )

like image 174
Igor Tkachenko Avatar answered Sep 19 '22 23:09

Igor Tkachenko