I am preparing an externs file for the pixijs library to work with the closure compiler. The only problem I encountered is the parameters of user objects. Here is a quick example:
pixi.js source:
/** * Set the style of the text * * @param [style] {object} The style parameters * @param [style.font='bold 20pt Arial'] {string} The style and size of the font * @param [style.fill='black'] {string|number} A canvas fillstyle that will be used on the text eg 'red', '#00FF00' * @param [style.align='left'] {string} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text
closing compiler output:
lib/pixi-externs.js:3266: WARNING - Parse error. invalid param name "style.font" * @param [style.font='bold 20pt Arial'] {string} The style and size of the font ^ lib/pixi-externs.js:3266: WARNING - Bad type annotation. missing closing ] * @param [style.font='bold 20pt Arial'] {string} The style and size of the font ^ lib/pixi-externs.js:3267: WARNING - Parse error. invalid param name "style.fill" * @param [style.fill='black'] {string|number} A canvas fillstyle that will be used on the text eg 'red', '#00FF00' ^ lib/pixi-externs.js:3268: WARNING - Parse error. invalid param name "style.align" * @param [style.align='left'] {string} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text ^
How can these pixijs annotations adapt to closing compiler annotations?
If this cannot be done with annotations, can I overcome this by defining a new object?
* @param {PIXI.TextStyleObject} style The style parameters
and creating a separate definition for the TextStyleObject, for example:
PIXI.TextStyleObject = {}; PIXI.TextStyleObject.font; PIXI.TextStyleObject.fill; PIXI.TextStyleObject.align;
What is the correct way to solve this problem?
source share