TypeScript has different interfaces mapping DOM events. (e.g. KeyboardEvent, MouseEvent, etc.). We can find them here.
For instance, they are handy in Angular when receiving an event's payload in an event listener.
I have been a bit surprised to be unable to find an interface for the SubmitEvent which is described here.
Can anyone confirm and explain why? I would expect the TypeScript team to share interfaces for every DOM event.
These do tend to get added over time. At the moment it is marked in the standard as "single implementation only", so it is more likely to be added when it has better adoption. (I believe it is in two engines now, so the standard will be updated to reflect that soon, I believe, as it will be in Chromium and Gecko).
You can use
Eventin all cases, unless you actually need to use the newersubmitter, which is the only addition theSubmitEventbrings to the table.If you do need
submitter, you can easily create yourSubmitEventand adjust theHTMLFormElementto use it - as shown below.When the library is updated, you'll be warned that
submitteris already declared and you can delete your temporary interface.