I'm trying to use Eclipse for some server-side Javascript development.
The API I use has a function doStuff(string, object)
(names changed to protect the guilty) that returns a value of differing types (subclasses of one type) depending on the (values of) the arguments passed it.
I have built a Javascript library to describe this function:
/**
* function doStuff(s, o)
* @memberOf Global
* @param {String} s
* @param {Object} o
* @type ResultType
* @returns {ResultType}
*/
doStuff = function(str, obj} {return new ResultType();}
Because it can return several types, I have declared it as returning the base type. However, that means Eclipse doesn't know what type it really is, and so I get later spurious errors when trying to access fields of that object.
So there can be FooResultType, BarResultType, each of which are ResultTypes, but have additional fields/functions
Is there any way around this? Can I somehow annotate the variable holding the returned value so that Eclipse knows what type it really is?
I've tried (with and without braces around FooResultType)
/**
* @type FooResultType
*/
v = doStuff("stringvalue", someObject);
but this makes no difference.
(There are other questions in this area, but nothing that address this issue, I think)