-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this
Milestone
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...
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this