0

我有一个继承的接口HTMLElement

export interface IEElement extends HTMLElement {
    click: (event: IEEvent) => void;
    onmousedown: (event: IEEvent) => void;
    onmousemove: (event: IEEvent) => void;
    onmouseup: (event: IEEvent) => void;
}

在所有属性上出现错误:

错误图像

我想这是因为clickis type () => void,但它不应该被我的新模式覆盖吗?如何省略错误(我不想重命名我的属性 - 如果没有必要)?

4

1 回答 1

1

使其成为可选(使用:?)

export interface IEElement extends HTMLElement {
    click: (event?: IEEvent) => void;
    onmousedown: (event: IEEvent) => void;
    onmousemove: (event: IEEvent) => void;
    onmouseup: (event: IEEvent) => void;
}
于 2013-01-15T14:21:37.890 回答