Closed
Description
While deprecated, the typings of MouseEvent.initMouseEvent()
should still support strict null checks.
TypeScript Version: 2.0.3
Code
let event = document.createEvent('MouseEvent') as MouseEvent;
// Initialize the mouse event data.
event.initMouseEvent(
'click', true, true, window, 0,
0, 0,
0, 0,
false, false,
false, false,
0, null // <--- Field `relatedTarget`. Error: null not accepted
);
Expected behavior:
MDN docs specify:
relatedTarget
the event's related EventTarget. Only used with some event types (e.g. mouseover and mouseout). In other cases, pass null.
So you would expect typing to read EventTarget | null
.
Actual behavior:
Null not accepted with strict null checks on.
Not sure whether any of the other fields should accept null
or undefined
as well...