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 decided 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 write its documentation. This workaround works OK.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.