2

I have a function which takes as arguments Express Request and Response objects.

function doStuff(req, res) {
  // do something
}

How to use jsdoc to document the types of req and res?

EDIT: The reasons I feel this is not a duplicate is that I am asking how to specifically use the Express classes as the types, where as the other questions suggest documenting it as Object and then documenting the properties

user3690467
  • 3,049
  • 6
  • 27
  • 54

1 Answers1

4

You can not only JsDoc the parameter types and descriptions, and but also their expected members.

/**
 * 
 * @module doStuff
 * @function
 * @param req {Object} The request.
 * @param res {Object} The response.
 * @param req.params.foo {String} The foo param.
 * @param req.query.bar {String} The bar query.
 * @param req.body {Object} The JSON payload.
 * @param {Function} next
 * @return {undefined}
 */
function doStuff(req, res, next){
}
Steven Spungin
  • 27,002
  • 5
  • 88
  • 78