A project I am on uses plugins, which export objects, and have their properties re-assigned to centralise functions.
Here is an example:
// barPlugin.js
const barPlugin = {
/**
* Register a Foo
* @param {string} name of the foo
* @param {object} options the options that make this foo special
* @param {string} options.flavour how the foo tastes
* @param {boolean} options.levitate if the foo can levitate
*/
registerFoos: (name, options = {}) => {
// stuff that registers foos
}
// other bar plugin related functions
}
export default barPlugin;
// pluginHub.js
const allPlugins = {};
export const initialisePlugins = () => { // called on app load
// hovering over 'registerFoos' on the LHS of the assignment does not show the jsdoc
allPlugins.registerFoos = barPlugin.registerFoo;
// LOTS of other examples of the above
}
export default allPlugins;
This is also so that when we need to register/interact with the foos
registered via the barPlugin
we only need to know it’s foos
and not which of the many many plugins it’s from.
The issue, now that we have started using JSDoc is that it seems like importing allPlugins
and calling allPlugins.registerFoos
no longer has the JSDoc associated with it?
// nonPluginCode.js
import allPlugins from 'pluginsHub';
allPlugins.registerFoos( ... ) // hovering over 'registerFoos' does not show the jsdoc
It feels like this might be an issue with VSCode, but regardless how can I preserve the JSDoc across the reassignment?
It’s not JSDoc broken on `exports.default` in VSCode? as this happens before exporting.