I am trying to extend an existing interface to add additional event handlers. The interface I am extending already has several event handlers defined.
Here is the base interface:
export interface Emitter {
on(event: 'connect', listener: (err: Error) => void ):this;
on(event: 'end', listener: () => void ):this;
}
Here is also the base class:
export class Emitter extends events.EventEmitter {}
Here is my interface:
export interface EmitterExtended extends Emitter {
on(event: 'status', listener: (status: ConnectionStatus) => void ):this;
status?: ConnectionStatus;
}
And here is the error typescript gives:
Interface 'EmitterExtended' incorrectly extends interface 'Emitter'.
Types of property 'on' are incompatible.