Event listeners

dompack improves on the standard addEventListener APIs by providing a stricter typed API if you're binding to (and only using) HTMLElements. By setting event.target to a stricter type than EventTarget your code doesn't need to work around various "'target' is possibly 'null'" and "Propery 'closest' does not exist on type 'EventTarget'" errors. We do this by proving a DocEvent<> wrapper for Event types that redefines (current)target and adding a addDocEventListener API to register these handlers.

eg

  this.node.addEventListener("click", evt => this._checkClick(evt));

  _checkClick(evt: MouseEvent) { .. };

should become

  addDocEventListener(this.node, "click", evt => this._checkClick(evt));

  _checkClick(evt: DocEvent<MouseEvent>) { .. };

addDocEventListener will also accept promise-returning listeners so you can directly use async() listeners. It will not actually do anything with the promise - don't expect it to eg. hold off incoming events until the previous event handler completes

addDocEventListener has been backported to WebHare 5.6.5