Javascript functions, webstorm doesn't seem to understand exposed public methods.

When you have a widely used function with some exposed public functions written as below, I find that webstorm doesn't understand the exposed public functions well.

For example if you do "convert parameters to object" on the loadData function it just breaks all the places that call the publicly exposed function. "Find usages" whilst technically correct is also a bit annoying as it requires using it twice from the function definition.

function dataLoader() {

const data = null;
const status = 'Not yet loaded';

function privateFunction { // code}
 function loadData(param1, param2, param3) { // code}
function cancelLoad() { // code}

return {loadData, cancelLoad, data, status}
}

I can workaround the issue with "convert parameters to object" by robotically inlining the function at the bottom of the JS file, then doing the "convert parameters to object" (this then refactors all the callers correctly) then I effectively undo the inline moving the function back into place. But the fact that I can do this following such prescriptive steps makes me feel webstorm should be capable of making it work without having to do the temporary inline.

Does anyone know if this is a known issue or if there is any feature request(s) for the IDE's to better understand publicly exposed functions in this style. I know some bits of webstorm work using this style, because calls to the publicly exposed function "loadData" show the parameter names in webstorm but the refactoring and search doesn't seem to work in the other direction well.

0

Please sign in to leave a comment.