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.
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 )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With