I'm making a node.js project, and work in Webstorm, where functions are usually highlighted in yellow. However in the following scenario, fnA
is not recognized as a function in file b.
//file a.js
module.exports = fnA;
/**
* Converts val to someOtherVal
* @param val
* @return someOtherVal
*/
function fnA( val ){
//Do something with val....
return someOtherVal
}
//file b.js
var fnA = requires('./a.js');
function fnB() {
var c = fnA(3); //<- not recognized as a function
}
However if I wrap the function in a namespace, it works properly:
//a.js
module.exports = fnA;
/**
* Converts val to someOtherVal
* @param val
* @memberof core
*/
function fnA( val ){
//Do something with val....
return someOtherVal
}
__________________________________________________
//b.js
/**
* @namespace
*/
var core = {
fnA : requires('./a.js')
}
function b() {
var c = core.fnA(3); //Recognized as a function
}
I would like to avoid wrapping the function in a namespace - what is the proper way to jsdoc the function in the first example?
same issue in JSDoc 3.6.6 (functions defined with an export not recognized)
Workaround: Define functions without export and export an object.