-1

I know that I can use jsdoc to declare that a function returns an Object.

/**
 *  Builds a body that returns published products
 * @param {string} rangeType
 * @param {string} retailUnit
 * @param {string[]} ids
 * @returns {Object}
 */
function fetchPublishedProducts(rangeType, retailUnit, ids) {
  return {
    size: 250,
    query: {
      ids: {
        values: ids.map(id => `${id}-${retailUnit}${rangeType ? `_${rangeType}` : ''}`),
      },
    },
  };
}

But what is the syntax if I want to declare that the return object has a size and a query property?

jonrsharpe
  • 107,083
  • 22
  • 201
  • 376
user1283776
  • 16,122
  • 38
  • 122
  • 229
  • Does this answer your question? [How to describe "object" arguments in jsdoc?](https://stackoverflow.com/questions/6460604/how-to-describe-object-arguments-in-jsdoc) – jonrsharpe Nov 11 '20 at 15:02

1 Answers1

1

Just define your object interface as:

/**
 * ....
 * @returns {{size: number, query: string}}
 */
Mr. R
  • 955
  • 1
  • 4
  • 13