我有兩個接口:IEvent
和IWorkflowResizedEvent
,它擴展了第一個接口。呼叫簽名在帶參數的接口中不兼容
interface IEvent {
add?(listener:()=> void): void;
remove?(listener:()=> void): void;
trigger?(...a: any[]): void;
}
interface IWorkflowResizedEvent extends IEvent {
add(listener:(args: WorkflowResizedEventArgs) => void): void;
remove(listener:(args: WorkflowResizedEventArgs) => void): void;
trigger(args: WorkflowResizedEventArgs): void;
}
interface WorkflowResizedEventArgs {
}
我得到一個錯誤:
Interface 'IWorkflowResizedEvent cannot extend interface 'IEvent': Types of property 'trigger' of types 'IWorkflowResizedEvent' and 'IEvent' are incompatible: Call signatures of types '(args: WorkflowResizedEventArgs) => void' and '(...a: any()) => void' are incompatible: Call signature expects 0 or fewer parameters.
我用之前的一些舊版本TypeScript
庫和這段代碼運行良好......現在我已經更新了庫到最新的一個並開始出現問題。我發現整個語言規範已經改變如此強烈...
有沒有人有任何想法這裏有什麼問題?它看起來應該沒問題。
謝謝M8!你是個紳士! – Nickon