如何让WebStorm/PhpStorm/IntelliJIDE识别module.exports类型?

How to enable WebStorm/PhpStorm/IntelliJ IDE to recognize module.exports type?

我无法让我的 IDE 知道模块函数的 return 类型。假设一个简单的节点模块是这样的:

function test() {
    return Promise.resolve("test");
}

module.exports = test;

现在像这样使用模块:

let test = require("./test");
test().then(text => {
    console.log(text); // prints "test" to console
});

但是 PhpStorm 总是抱怨 then 函数:

Unresolved function or method then()

我什至尝试将 JSDoc 添加到 test() 函数,如下所示:

/**
 * test
 * @returns {Promise}
 */
function test() {
    return Promise.resolve("test");
}

没有任何帮助。有没有我做错了什么或有其他方法可以使它正常工作?

这是一个已知错误,请关注WEB-24161更新