New Sails JS answer in WebStorm

I'm new to Sails JS .. I'm trying to create a new custom answer, I didn't find any autogenerator, so I created it manually.

//someName.js    
module.exports = function someName(data, options) {
    console.log('test');
};

      

I'm trying to access this answer from a controller:

//someController.js
module.exports = {
    someController: function(req, res) {
        res.someName();
    }
}

      

The problem is that WebStorm doesn't recognize this response.

Unresolved function or method someName.

But when the app is running - it works .. (WebStorm recognizes the default responses that come with "new someApp sails").

Thank you for your help!

+3


source to share


1 answer


The code in the Sails.js library that loads custom responses probably does something like this:

files = getFilesInApiResponsesDirectory()
files.forEach(function(file) {
  name = extractName(file);
  res[name] = require(file); // <-- too dynamic to infer at this point
})

      



It is not possible for the WebStorm code analyzer to be able to make a connection between res

and your custom response function without actually running the Sails.js code or getting a hint (less dynamic, more explicit).

In any case, the message you receive does not necessarily represent a fatal error, it is a "code check", you can disable or suppress .

+2


source







All Articles