Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddEventListenerOptions not available in Document, HTMLDivElement and others #18136

Closed
HolgerJeromin opened this issue Aug 30, 2017 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@HolgerJeromin
Copy link
Contributor

HolgerJeromin commented Aug 30, 2017

TypeScript Version: 2.4.1

addEventListener has now an object third param type. Some were included in #15183 (closing #14188 )

But this is not fixed for Document and others in TS 2.4.1 (and ts playground)

document.addEventListener('readystatechange', function () { }, { once: true });
document.createElement('div').addEventListener('click', function () { }, { once: true });

Update:
HTMLDivElement extends HTMLElement (with own addEventListener for special this)
HTMLElement extends Element (with own addEventListener for special this)
Element extends Node (with own addEventListener for special this)
Node extends EventTarget
EventTarget (with addEventListener with unspecific this)

@mhegazy mhegazy added Help Wanted You can do this Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Aug 30, 2017
@mhegazy mhegazy added this to the Community milestone Aug 30, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Aug 30, 2017

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

@HolgerJeromin
Copy link
Contributor Author

HolgerJeromin commented Oct 26, 2017

@mhegazy @thebanjomatic
The current state now in master is a breaking change in TS2.6

microsoft/TypeScript-DOM-lib-generator#312 (ported in #19426) added an own removeListener to document which overwrites the working signature from EventTarget with the "buggy" one without the options.

document.removeEventListener('keydown', myHandler, options);
compiles in TS2.5 but not in TS2.6

@thebanjomatic
Copy link

thebanjomatic commented Oct 26, 2017

@mhegazy Do you see any reason to not just emit the useCapture?: boolean|AddEventListenerOptions in the generator? There are also a handful of types which add signatures through addedTypes that need to be updated, but I think I will make this change and submit another pull request.

thebanjomatic pushed a commit to thebanjomatic/TSJS-lib-generator that referenced this issue Oct 26, 2017
For the signatures generated within TS.fsx:
* Changes the type of the third argument to `boolean | AddEventListenerOptions` for `addEventListener`
* Changes the type of the third argument to `boolean | EventListenerOptions` for `removeEventListener`

Additionally, there were a few changes in addedTypes.json that needed to be updated by adding `removeEventListener` signatures and updating both `addEventListener` and `removeEventListener` to allow options:
* BroadcastChannel
* IDBDatabase

microsoft/TypeScript#18136
thebanjomatic pushed a commit to thebanjomatic/TSJS-lib-generator that referenced this issue Oct 26, 2017
For the signatures generated within TS.fsx:
* Changes the type of the third argument to `boolean | AddEventListenerOptions` for `addEventListener`
* Changes the type of the third argument to `boolean | EventListenerOptions` for `removeEventListener`

Additionally, there were a few changes in addedTypes.json that needed to be updated by adding `removeEventListener` signatures and updating both `addEventListener` and `removeEventListener` to allow options:
* BroadcastChannel
* IDBDatabase

microsoft/TypeScript#18136
@mhegazy mhegazy added the Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet label Oct 26, 2017
@mhegazy mhegazy self-assigned this Oct 26, 2017
@mhegazy mhegazy modified the milestones: Community, TypeScript 2.7 Oct 26, 2017
@mhegazy mhegazy added Fixed A PR has been merged for this issue and removed Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet labels Nov 21, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants