简体   繁体   English

JSDOC 在 socket.io 发出

[英]JSDOC on socket.io emit

If I have socketio function like this:如果我有这样的 socketio function:

_sock.emit('app_version',appversion,(response)=>{
   console.log(response)
})

and I want to put a proper JSDOC, explaining that appversion is a string, and response is a string, how do i write it?我想放一个适当的 JSDOC,解释 appversion 是一个字符串,而 response 是一个字符串,我该如何写呢?

currently tried some combination like @param, or @property in WebStorm, yet Webstorm still don't recognize that appversion and response type.目前在 WebStorm 中尝试了一些组合,如 @param 或 @property,但 Webstorm 仍然无法识别该应用程序版本和响应类型。

Kindly help请帮忙

JSDoc works best if you type things as you declare them, which doesn't work very well if you're doing things inline (such as using an inline arrow function. Try something like this, declaring and typing your variables and functions before using them:如果您在声明时键入内容,JSDoc 效果最好,如果您在内联执行操作(例如使用内联箭头 function),则效果不佳。尝试这样的操作,在使用变量和函数之前声明并键入它们:

// Use @type to indicate the type of the next following variable
/**
 * @type {string}
 */
let appversion;

// Use @param to indicate the param type of the next following function
/**
 * @param {string} response
 */
function doThing(response) {
  console.log(response);
}

_sock.emit('app_version', appversion, doThing);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM