Skip to content

AddEventListenerOptions not available in Document, HTMLDivElement and others #18136

Closed

Description

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)

Activity

  1. added this to the milestone on Aug 30, 2017
  2. mhegazy commented on Aug 30, 2017

    @mhegazy
    Contributor

    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.

  3. HolgerJeromin commented on Oct 26, 2017

    @HolgerJeromin
    ContributorAuthor

    Mohamed Hegazy (@mhegazy) Adam Hines (@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

  4. thebanjomatic commented on Oct 26, 2017

    @thebanjomatic

    Mohamed Hegazy (@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.

  5. modified the milestones: , TypeScript 2.7 on Oct 26, 2017
  6. added
    FixedA PR has been merged for this issue
    and removed
    Fixed in TSJS repoFix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet
    on Nov 21, 2017
  7. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions