我正在为pixijs库准备externs文件以使用闭包编译器.到目前为止我唯一的问题是使用自定义对象参数.这是一个简短的例子:
pixi.js来源:
/** * 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
闭包编译输出:
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 ^
这些pixijs注释如何适应闭包编译器注释?
如果没有办法通过注释实现这一点,我可以通过定义一个新对象来克服这个问题吗?
* @param {PIXI.TextStyleObject} style The style parameters
并创建一个单独的TextStyleObject对象定义?
PIXI.TextStyleObject = {}; PIXI.TextStyleObject.font; PIXI.TextStyleObject.fill; PIXI.TextStyleObject.align;
解决这个问题的正确方法是什么?