I've created function description using JSDoc @param
annotation as follows (using Visual Studio "Add jsdoc comments" plugin). But for default parameters of the function doesn't come with its data type. Even if I checked the JSDoc, I didn't find whether this is the correct syntax to describe default parameters.
Therefore, can anyone confirm whether "Add jsdoc comments" plugin does follow the correct syntax on describing functions.
Check invoiceUpdate
parameter below (here I'm using TypeScript).
/**
* @param {string[]} invoiceIds
* @param {string} token
* @param {} invoiceUpdate=false
* @returns Promise
*/
public async calculateInvoices(
invoiceIds: string[],
token: string,
invoiceUpdate = false,
): Promise<string> {
/*
function body
*/
}
CodePudding user response:
In order to describe optional parameter with default value, according to the docs you should use this syntax:
/**
* @param {string} [somebody=John Doe] - Somebody's name.
*/
So, your code, should be like this:
/**
* @param {string[]} invoiceIds
* @param {string} token
* @param {boolean} [invoiceUpdate=false] invoiceUpdate
* @returns Promise
*/
const calculateInvoices=(
invoiceIds,
token,
invoiceUpdate = false,
)=> {
/*
function body
*/
}
calculateInvoices(['sdf'],'sdf')