Search code examples
javascriptwebstormtypedefjsdoc

Proper JSDoc typedef declaration of function with optional arguments in javascript


Given following typedef

/***
 * @typedef {object} Queue
 * @property {function(string):string[]} listQueueNames Gets an optionally 
   filtered list of QueueNames. 
 */

What is a proper way to mark listQueueName's Argument as an optional Argument ?


Solution

  • Using Closure Compiler syntax should work here:

    /***
     * @typedef {object} Queue
     * @property {function(string=):string[]} listQueueNames Gets an optionally 
       filtered list of QueueNames. 
     */