[英]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?如何记录 object 属性/方法,当此属性/方法稍后添加到 object后,在 object 已初始化后?
Example:例子:
Let's say that I declare the following object.假设我声明了以下 object。 Documentation of
ID
and name
work fine: ID
和name
的文档工作正常:
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):后来,我决定添加一个属性(假设在另一个 js 文件中):
/** The role of the AppUser */
App.role = "admin";
In that case, App.role
's documentation does not work.在这种情况下,
App.role
的文档不起作用。 At least, VSCode does not open the tooltip to inform me about its description.至少,VSCode 不会打开工具提示来通知我它的描述。
What I do now, is declare an empty property inside the object: role:null,
and also write its documentation.我现在要做的是在 object:
role:null,
并编写它的文档。 This workaround works OK.此解决方法工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.