[英]How to document an object property?
How can I document an object property with the object properties expected? 如何使用期望的对象属性记录对象属性? For instance, if the object was this:
例如,如果对象是这样的:
var Object = {
/**
*
*/
point: null
}
and the point had this structure: 而这一点有这样的结构:
{
x,
y
}
Is there anyway to say that the point should have the x and y property? 反正有没有说这个点应该有x和y属性? Well, of course I can do it in the description, but I was looking for a better way to do it, like in the params that we can do like this:
好吧,当然我可以在描述中做到这一点,但我一直在寻找一种更好的方法,比如我们可以这样做的参数:
/**
* @param {Object} point
* @param {Number} point.x
* @param {Number} point.y
*/
You could always make a Point
class. 你总是可以创建一个
Point
类。
function Point(x, y) {
this.x = x;
this.y = y;
}
Then 然后
var Object = {
/**
* new Point(x, y)
* @param {Point} point a point class
*/
point: null
}
Other wise I would do 其他明智的我会这样做
/*
* @param {Object} point {x, y}
*/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.