Closed Fredx87 closed 6 years ago
I think the long
on*
list is pretty awesome but the concept here is that any event, even custom events, starting withon
will work just as fine.
These definitions are needed because the HTMLElement
interface have these handlers defined as properties: https://github.com/Microsoft/TypeScript/blob/be1c11581e43098bcb6747af50f43b39c762be39/lib/lib.d.ts#L8755 and if you try to write a method that have the same name of a property Typescript will throw an error like this:
TS2425: Class 'HyperHTMLElement<{}>' defines instance member property 'onclick', but extended class 'MyCustomComponent' defines it as instance member function.
Redefining all the handler as methods in the HyperHTMLElement interface fixes this problem.
Added definitions for typescript and examples.