📖JSDoc
TypeScript ⟩ JSDoc Reference
if you write three or more stars (*), the comment will be ignored;
/** <-- ⭐️ JSDoc expects two stars (no more, no less)
*
*/TypeScript in 50 Lessons (2020), Lesson 4: Adding Types with JSDoc
Modern JavaScript Web Development Cookbook (2018) ⟩ Documenting your code with JSDoc
Google Apps Script ⟩ play JSDoc
GitHub ⟩ vscode-docthis - auto-generated JSDoc.
VSCode ⟩ Document This (vscode-docthis?)
DevHints ⟩ JSDoc cheatsheet
/**
* Adds VAT to a price
*
* @param {number} price The price without VAT
* @param {number} vat The VAT [0-1]
*
* @returns {number}
*/
function addVAT(price, vat = 0.2) {
return price * (1 + vat)
}// defining objects
/**
* @typedef {Object} Article
*
* @property {number} price
* @property {number} vat
* @property {string} string
* @property {boolean=} sold (⭐️ optional property)
*/
// ⭐️ optional property/parameter syntax:
// • @param {boolean=} sold
// • @param {boolean} [sold]
/**
* Now we can use `Article` as a proper type
*
* @param {[Article]} articles
*/
function totalAmount(articles) {
return articles.reduce((total, article) => {
return total + addVAT(article) }, 0)
}Last updated
Was this helpful?