I can't understand why this will give me an error (with compiler option "strict": true).
class EventX {
public type: string
constructor(type: string) {
this.type = type
}
}
class ClickEvent extends EventX {
public x: number
constructor(type: string, x: number) {
super(type);
this.x = x;
}
}
interface Events {
[eventType: string]: (event: EventX) => any
click: (e: ClickEvent) => any // TS2411: Property 'click' of type '(e: ClickEvent) => any' is not assignable to string index type '(event: EventX) => any'.
}
By the way this works fine
interface Events {
[eventType: string]: EventX
click: ClickEvent
}
So I think is this part (event: EventX) => any cause the problem. But what's wrong with this? How can I fix it?