I don't know how much of this (if any) is related to Google Closure or if it's all clean jsdoc, but I tried using @typedef to define a specific type of function like this;
/**
* @typedef {function(paramType0, paramType1):returnType} name.space.and.TypeName
*/
also tried
/**
* @typedef {function(paramType0, paramType1):returnType}
*/
name.space.and.TypeName;
where param and return types are the reason I want to define this specification of function. My question is this;
Why do validation tell me that the "Method is not of Function type". I know it's an option to use the type 'Function', but as far as I know, that won't allow me to define parameter and return types? Am I wrong on this as well?
I would much appreciate some assistance on this in any case. Thanks.
Typical use of a typedef looks like this:
/** @typedef {function():string} */
var SomeFunctionType;
/** @param {SomeFunctionType} x This is a function */
function useFunction(x) {
...
}
The question is lacking some detail and I expect you actually want a @type declaration to type a value, rather than creating a type name:
/** @type {function():string} */
var someFunction = getFunctionFromSomewhere();
someFunction();
An overview of the jsdoc annotation can be found here: https://developers.google.com/closure/compiler/docs/js-for-compiler
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