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

159
Views
JSDoc - Documentation for object property that is defined later

How to document an object property/method, when this property/method gets added to the object later, after the object has been initialized?

Example:

Let's say that I declare the following object. Documentation of ID and name work fine:

let AppUser = {
   /** The user's id */
   ID: 0,
   /** The user's name */
   name: "guest",
};

Later, I decide to add a property (let's say in another js file):

/** The role of the AppUser */
App.role = "admin";

In that case, App.role 's documentation does not work. At least, VSCode does not open the tooltip to inform me about its description.

What I do now, is declare an empty property inside the object: role:null, and also writing its documentation. This workaround works OK.

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!