Skip to content

Event type for readystatechange is not specific enough #41775

Closed as not planned
Closed as not planned
@jurosh

Description

@jurosh

TypeScript Version: 4.1.0 (probably all)

Search Terms: readystatechange, ProgressEvent

Code

document.addEventListener('readystatechange', event => {
  if (event.target?.readyState === 'complete') {
    // ready state
  }
});

Expected behavior:
For readystatechange event, when calling from document.addEventListener there is only single event target allowed and that is Document itself.
Spec:

So code above should be executable without typescript errors.

Actual behavior:
Currently there is no information about event.target. It's pointing to generic event interface.

Playground Link

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