我从 Kinetic.d.ts 下载了Kinetic.d.ts
它缺少标签插件,所以我正在尝试创建它。
我建立:
class Label extends Group
{
constructor(config: LabelConfig);
setText(text: Text);
getText(): Text;
setRect(rect: LabelRect);
getRect(): LabelRect;
}
class LabelRect extends Shape
{
constructor(config: LabelRectConfig);
setPointerDirection(pointerDirection: string);
setPointerWidth(pointerWidth: number);
setPointerHeight(pointerHeight: number);
setCornerRadius(cornerRadius: number);
getPointerDirection(): string;
getPointerWidth(): number;
getPointerHeight(): number;
getCornerRadius(): number;
}
interface LabelConfig extends DrawOptionsConfig, ObjectOptionsConfig
{
rect: LabelRect;
text: Text;
}
interface LabelRectConfig extends DrawOptionsConfig, ObjectOptionsConfig
{
pointerDirection?: string;
pointerWidth?: number;
pointerHeight?: number;
cornerRadius?: number;
}
我收到此错误(我将错误格式化以供阅读):
Error 1 Supplied parameters do not match any signature of call target:
Could not apply type 'LabelConfig' to argument 1, which is of type
'{
x: number;
y: number;
opacity: number;
listening: bool;
text:
{
text: string;
fontFamily: string;
fontSize: number;
padding: number;
fill: string;
};
rect:
{
fill: string;
pointerDirection: string;
pointerWidth: number;
pointerHeight: number;
lineJoin: string;
};
}'
我正在实例化标签,例如:
var labelNumerator = new Kinetic.Label(
{
x: LEFT_MARGIN + numerator.getTextWidth() + 50,
y: numerator.getY() + 5,
opacity: 0.75,
listening: false,
text: {
text: 'Numerator',
fontFamily: FONT,
fontSize: LABEL_FONT_SIZE,
padding: LABEL_PADDING,
fill: LABEL_TEXT_COLOR
},
rect: {
fill: LABEL_BACKGROUND_COLOR,
pointerDirection: 'left',
pointerWidth: LABEL_FONT_SIZE + LABEL_PADDING * 2,
pointerHeight: LABEL_FONT_SIZE + LABEL_PADDING * 2,
lineJoin: 'round'
}
}
);
我错过了什么?