0
我有一个如下所示的函数。IDE不识别使用JSDoc的方法
/**
* @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的文档:https://www.jetbrains.com/help/webstorm/2016.3/creating-jsdoc-comments.html –