如何使用JSDoc注释核心Node.js模块以在IntelliJ中进行代码提示? [英] How to annotate core Node.js modules with JSDoc to have code hinting in IntelliJ?

查看:109
本文介绍了如何使用JSDoc注释核心Node.js模块以在IntelliJ中进行代码提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我需要其中两个, util fs 。给出这样的代码:

So far I have a need for two of them, util and fs. Given a code like this:

var fs = require('fs');
var contents = fs.readFileSync('path/to/file', 'utf8');

不仅IntelliJ标记 readFileSync as 未解决的功能或方法,但在我看来,我也缺乏IDE提供的最佳功能 - 代码提示。

Not only IntelliJ marks readFileSync as Unresolved function or method, but I am also devoid of, in my opinion, on of the best function given by IDEs - code hinting.

怎么能我使用JSDoc注释核心Node.js函数以获得代码提示并且没有错误地将错误标记为无效的正确代码?

How can I annotate core Node.js functions with JSDoc to have code hinting and not have correct code erroneously marked as invalid?

推荐答案

为什么选择核心库没有解析?



无效代码的问题是你有不是NodeJS项目。

Why core libraries are not resolved?

The issue with the invalid code is that you have "not NodeJS project".

你应该安装NodeJS插件: http://plugins.jetbrains.com/plugin/6098?pr=phpStorm

You should install the NodeJS plugin: http://plugins.jetbrains.com/plugin/6098?pr=phpStorm

然后创建新项目使用给定的来源。

IntelliJ将自动覆盖元数据,挂钩NodeJS环境,所有核心模块都将被解析。

IntelliJ will automatically overwrite the metadata and hook the NodeJS environment and all your core modules will be resolved.

IntelliJ尝试很难确定对象签名,但是一些JS编码技术会阻止你IDE读取签名(只能在运行时读取)。

IntelliJ tries hard do determine the object signature, but some JS coding techniques prevent your IDE from reading the signature (it can be read only in runtime).

关于类型注释,您可以在这里查看,例如: https://groups.google.com/forum/#!topic/ scripted-dev / xFtPiBJDO4c

Regarding the type annotation you can have a look here, for example: https://groups.google.com/forum/#!topic/scripted-dev/xFtPiBJDO4c

更新:我写了一篇描述如何y的文章您可以在IntelliJ IDEA中启用NodeJS的类型提示: http:// www .fse.guru / nodejs-autocomplete-in-idea-and-webstorm

Update: I have written an article describing how you can enable the type hinting for NodeJS in IntelliJ IDEA: http://www.fse.guru/nodejs-autocomplete-in-idea-and-webstorm

这篇关于如何使用JSDoc注释核心Node.js模块以在IntelliJ中进行代码提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆