【发布时间】:2016-03-12 00:47:06
【问题描述】:
我正在为 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;
解决这个问题的正确方法是什么?
【问题讨论】:
标签: javascript google-closure-compiler jsdoc pixi.js