【发布时间】:2017-02-14 08:15:46
【问题描述】:
我有一个定义如下的函数。
/**
* @type Object
* @return {typeof hello} hello
*/
function hello() {
/**
* Prints some words
* @param {string} words - words to print
* @returns {string} words you said
*/
function sayIt(words) {
console.log(words);
return 'You said: ' + words;
}
return {
sayIt: sayIt
}
}
我希望这样当我输入 hello. 时,我的 IDE 会告诉我方法 sayIt 可用,并且它接收参数 words 作为字符串。
此函数作为模块加载到云系统中,您可以从另一个脚本调用它的唯一方法是导入 hello 模块并像 hello.sayIt('hello') 一样使用它。所以基本上我想知道是否有一种方法可以格式化 JSDoc,以便我的 IDE 知道 sayIt 方法可用于 hello 对象,并且它将 words 参数作为字符串接收。目前它知道sayIt是一个方法但不知道它与hello对象相关联,所以我没有得到任何自动完成帮助。
【问题讨论】:
-
所以,你一直在说“IDE”,但从标签来看,你真正的意思是 WebStorm。帮助中有关于如何正确添加 JSDoc 的文档:jetbrains.com/help/webstorm/2016.3/creating-jsdoc-comments.html
标签: javascript function webstorm jsdoc