Search code examples
node.jssequelize.jswebstorm

Warning at sequelize magic association method


I'm having warning at sequelize magic method in my WebStorm IDE. The code running fine so there is no error in the code but the IDE just doesn't recognize it.

enter image description here

All other methods by sequilze are recognised by the IDE apart from this one. This is how I importing Sequelize

const Sequelize = require('sequelize').Sequelize;

const sequelize = new Sequelize('test-schema', 'root', 'mypassword', {dialect: 'mysql', host: 'localhost'});

Here are my JS library in preferences

enter image description here

I tried to add new library @types/sequelize with no luck

Any idea how to fix it?


Solution

  • The method is not defined statically anywhere, it's generated dynamically in runtime. In such case, there is no way for the IDE to resolve it using static code analysis... You can disable WebStorm inspections if shutting them up, making the code 'green', is the only requirement. Like:

    // noinspection JSUnresolvedFunction
    req.user.createProduct({
    

    Recognizing such methods would require adding special support for Sequelize by developing a plugin. You can find basic documentation about plugin development here: http://www.jetbrains.org/intellij/sdk/docs/. Some open source plugins can be found at https://github.com/JetBrains/intellij-plugins.

    I can also suggedst filing a feature request for providing Sequelize support to youtrack, https://youtrack.jetbrains.com/issues/WEB