Question

I have the following NodeJS module

/**
 * @param {string} a 
 * @param {string} b
 * @return {Object}
 */
module.exports = function(a, b) {
  return {
    foo: function(a, b, c) {}
  };
}

I then load the module and try to use the results

var Factory = require("./my-module.js");
var configuredObject = Factory(1, 2);

configuredObject.foo(1, 2, 3);  <-- Unresolved function or method foo()

I had a look at some other suggestions on SO and related links however the suggestion of replicating the outline of the Object so that I could then use JSDoc seems very dirty as I would have to manually copy/paste the outline into every user of the module, which is tedious, and of course very error prone eg:

var MyModuleOutline = {
  foo: function(a, b, c) {} 
}

/** @type {MyModuleOutline} */
var configuredObject = Factory(1, 2);

I'm using phpStorm 7.1, and I'm hoping that there's been improvements with code completion/understanding that I just don't know about yet.

What else can I do to remove the "Unresolved function" message?

Was it helpful?

Solution

Some ways to document properties of the returned object are described here and here. But none of them will actually work in WebStorm. And properties resolving should work in your case without JSDoc. Logged as WEB-11755

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top