jsdoc where to put typedef code example
Example 1: define all jsdoc typedef in a seperate file
// user.js
const checkAge = require('./user-helper')
/**
* @typedef {Object} User
* @property {string} name
* @property {number} age
*/
/**
* @param {User} user
*/
const createUser = (user) => {
if (checkAge(user)) {
db.save(user)
}
}
Example 2: define all jsdoc typedef in a seperate file
// user-helper.js
/**
* @param {import('./user').User} user
*/
exports.checkAge = user => {
return user.age >= 18
}