define all jsdoc typedef in a seperate file code example
Example 1: define all jsdoc typedef in a seperate file
// user-helper.js
/**
* @param {import('./user').User} user
*/
exports.checkAge = user => {
return user.age >= 18
}
Example 2: 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)
}
}