Reputation: 43
In javascript code, I have this function
/*
* @param
* @return
*/
foo = function (oObjFoo) {
// do something
return oObjBar;
}
oObjFoo is type : {"a":number, "b":text, "c": bool }
oObjBar is type : {"c":number, "d":text }
How do I specify the @param, @return to do much stricter type check with the google closure compiler?
Upvotes: 0
Views: 137
Reputation: 22116
/**
* @param {{a:number, b:string, c: boolean }} oObjFoo
* @return {{c:number, d:string}}
*/
var foo = function (oObjFoo) {
// do something
return oObjBar;
}
Note that the comment must start with a double asterisk for the compiler to count it as a JsDoc comment.
Upvotes: 2
Reputation: 1378
Take a look at JSDoc:
http://usejsdoc.org/tags-param.html
/**
* @param {Object} oAttributes
* @param {namespace.extension=} oAttributes.parent DOC-Description
* @param {jQuery=} oAttributes.$element Optional jQuery-Element
*/
Upvotes: 0