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

Event type for readystatechange is not specific enough #41775

Closed
jurosh opened this issue Dec 2, 2020 · 5 comments
Closed

Event type for readystatechange is not specific enough #41775

jurosh opened this issue Dec 2, 2020 · 5 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@jurosh
Copy link

jurosh commented Dec 2, 2020

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

@jurosh
Copy link
Author

jurosh commented Dec 2, 2020

I've tried to make PR which would fix this #41776

  • but problem is that file I edited is generated (and bot closed it) 😞
    I am not sure right now what is source of those typings, can take closer look later, or if someone can give me hand I can update accordingly

@jurosh
Copy link
Author

jurosh commented Dec 2, 2020

Seems it would be required to modify https://github.com/microsoft/TypeScript-DOM-lib-generator/ and I have no idea how.
Please feel free to close issue if that is too much effort for just small typing security benefit.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this labels Dec 3, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Dec 3, 2020
@RyanCavanaugh
Copy link
Member

That's the right repro for the fix, but we track the issues here sometimes too

@jonhue
Copy link
Contributor

jonhue commented Feb 25, 2021

@RyanCavanaugh I suggest closing this here as @orta made a valid case against making the type more specific here (microsoft/TypeScript-DOM-lib-generator#969 (comment)).

@RyanCavanaugh
Copy link
Member

Agreed

@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
3 participants