Skip to content

DOM scroll event is UIEvent, but should be Event #18355

@bradleyayers

Description

@bradleyayers

TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)

Code

document.addEventListener("scroll", e => {
    e.view;
});

Expected behavior:

This should not type check, as view does not exist on Event. I ran into this because in Chrome (I tested on Chrome 60) event.view is undefined for scroll events. There's a Chromium issue from 2015 about emitting a UIEvent and is marked as WontFix, saying:

We intend to update the UIEvent spec to be consistent with this since we don't believe that anyone creates a UIEvent for 'scroll'.

The spec is updated and shows that scroll events should just be an Event rather than a UIEvent.

Actual behavior:

e is considered a UIEvent, which does have a view property, and so the code type checks successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions