简体   繁体   中英

JSDOC on socket.io emit

If I have socketio function like this:

_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?

currently tried some combination like @param, or @property in WebStorm, yet Webstorm still don't recognize that appversion and response type.

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:

// 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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