El compilador de Cierre de Google tiene una etiqueta "@typedef", pero ¿está bien utilizarlas en su código? (Sé que va a trabajar, pero ¿es mal visto?)Uso de la etiqueta @typedef de Google Closure
Así que aquí es mi tipo
/** * The plan object's typedef * @typedef {Object} */ Types.Plan = { "style": "bordersmall", "width": "50%", "height": "40%", "x": "20%", "y": "10%", "clickable": true, "moveable": true };
y luego puedo usar ese tipo en mis anotaciones jsdoc.
Esto permite a mi IDE dame autocompletar en el parámetro pasado
lo tanto, el objeto declarado no se utiliza en cualquier parte del código.
/** * The Instructions class * @param {Types.Plan} plan Plan for position and dimension * @param {Manager} manager The manager * @param {Instructions} parent This widget's parent's instructions * @return {Instructions} Returns the new instructions object */ Instructions = function(plan, manager, parent){ plan. }
¿Esto es así? ¿O hay una mejor solución?
También es útil para uniones: '/ ** @typdef {string | number | boolean} */var myType;' –