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.
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.
Share Improve this question asked Apr 6, 2015 at 15:20 NinjaToolNinjaTool 631 silver badge5 bronze badges 1- Sounds like you are miss using the typedef, how are you using the declared type? (The second form is more correct). – John Commented Apr 9, 2015 at 0:19
1 Answer
Reset to default 5Typical 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./closure/piler/docs/js-for-piler
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744867345a4598053.html
评论列表(0条)