// @declaration: true // @emitDeclarationOnly: true // @allowJs: true // @checkJs: true // @module: commonjs // @target: es6 // @filename: file.js /** * @namespace myTypes * @global * @type {Object} */ const myTypes = { // SOME PROPS HERE }; /** @typedef {string|RegExp|Array} myTypes.typeA */ /** * @typedef myTypes.typeB * @property {myTypes.typeA} prop1 - Prop 1. * @property {string} prop2 - Prop 2. */ /** @typedef {myTypes.typeB|Function} myTypes.typeC */ exports.myTypes = myTypes; // @filename: file2.js const {myTypes} = require('./file.js'); /** * @namespace testFnTypes * @global * @type {Object} */ const testFnTypes = { // SOME PROPS HERE }; /** @typedef {boolean|myTypes.typeC} testFnTypes.input */ /** * @function testFn * @description A test function. * @param {testFnTypes.input} input - Input. * @returns {number|null} Result. */ function testFn(input) { if (typeof input === 'number') { return 2 * input; } else { return null; } } module.exports = {testFn, testFnTypes};