Reputation: 2747
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
*/
}
Upvotes: 6
Views: 15882
Reputation: 33101
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')
You can find also a lot of information in recently updated typescript JSDocs page
Upvotes: 9