Skip to content

[Web API type definition issue] HTMLDocument shouldn't be deprecated #1997

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

Closed
3 tasks done
Bashamega opened this issue Apr 24, 2025 · 4 comments · Fixed by #1998
Closed
3 tasks done

[Web API type definition issue] HTMLDocument shouldn't be deprecated #1997

Bashamega opened this issue Apr 24, 2025 · 4 comments · Fixed by #1998

Comments

@Bashamega
Copy link
Contributor

Summary

For some reson Typescript says HTMLDocument is deprecated, but it is not

Expected vs. Actual Behavior

Even though MDN says it is widely available, TypeScript says it is deprecated.

Playground Link

https://www.typescriptlang.org/play/?#code/CYewxgrgtgpgdgFwAQEs4GcEEM5hiAMyQAkAVAWQBkARcaeBIA

Browser Support

  • This API is supported in at least two major browser engines (not two Chromium-based browsers).

Have Tried The Latest Releases

  • This issue applies to the latest release of TypeScript.
  • This issue applies to the latest release of @types/web.

Additional Context

No response

@jakebailey
Copy link
Member

It exists widely doesn't necessarily mean it's good to use; I would double check the history to understand why this was deprecated.

@Bashamega
Copy link
Contributor Author

It exists widely doesn't necessarily mean it's good to use; I would double check the history to understand why this was deprecated.

It is true that it is not the best option to use in modern days, but browsers support it according to MDN.

Also, sometimes we need to use it. These are some use cases
1 - Accessing HTML-Specific Properties or Methods
2 - Type Narrowing for Specific Document Types
3 - Custom HTML Document Handling

@saschanaz
Copy link
Contributor

HTMLDocument is just an alias of Document and it's correct that it shouldn't be used.

@saschanaz
Copy link
Contributor

That said, browsers haven't follow the deprecation and still have HTMLDocument, and per whatwg/dom#221 the consensus seems to be that the deprecation isn't worth doing. Maybe we should follow the consensus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants