【问题标题】:WebStorm cannot go to declaration for node js module's methods?WebStorm 不能去声明节点 js 模块的方法?
【发布时间】:2020-07-17 07:32:23
【问题描述】:

我正在使用一些模块,并且每个模块在使用 WebStorm 作为我的 IDE 时都有同样的问题。例如:

const yargs = require('yargs');
yargs.parse()

每当我尝试去声明parse() 时,它都会失败,Cannot find declaration to go to 错误。像这样:

我的文件结构如下:

并启用编码辅助:

【问题讨论】:

    标签: node.js webstorm jetbrains-ide


    【解决方案1】:

    yargs 属性是动态生成的,因此在静态代码分析期间无法解析。

    安装类型(使用npm install @types/yargs,或通过Alt+Enter 提供的意图 - 请参阅https://www.jetbrains.com/help/webstorm/configuring-javascript-libraries.html#ws_jsconfigure_libraries_ts_definition_files)应该会有所帮助

    【讨论】:

    • 谢谢,这很有帮助。开发人员是否必须为他们在 npm 上开发和部署的每个库提供 @type?
    猜你喜欢
    • 2017-07-07
    • 2017-04-05
    • 2016-10-06
    • 2019-01-14
    • 2012-05-28
    • 2017-09-30
    • 1970-01-01
    • 1970-01-01
    • 2014-07-22
    相关资源
    最近更新 更多