Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
How can I preserve the JSDoc on re-assignment in VSCode?

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!