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

Allow the use of types without using the DOM lib #6989

Closed
remcohaszing opened this issue Mar 14, 2021 · 0 comments · Fixed by #6998
Closed

Allow the use of types without using the DOM lib #6989

remcohaszing opened this issue Mar 14, 2021 · 0 comments · Fixed by #6998

Comments

@remcohaszing
Copy link
Contributor

Sometimes one wants to use puppeteer without using the DOM directly. I.e. in remark-mermaidjs I want to allow users to specify puppeteer launch options, but users of this library don’t have to interact with the DOM in any way. I’ve identified puppeteer uses the following types in `lib/types.d.ts:

  • Document
  • Element
  • NodeList

I believe these types can be stubbed in a similar way as I did here

/**
 * This is a stub implementation to prevent the need to use dom types with puppeteer.
 *
 * To enable proper Element types, add `"dom"` to `"lib"` in your `tsconfig.json`.
 */
interface ElementStub {}

type Element = globalThis extends { window: any } ? Element : ElementStub
jschfflr pushed a commit that referenced this issue Sep 11, 2021
The dom lib inserts all dom related types into the project, which is often
undesirable when working on a NodeJS project.

This change injects global stubs for the dom types required by puppeteer, so
puppeteer can work without users having to add dom types to their project.

Closes #6989
jschfflr pushed a commit to mushishi78/puppeteer that referenced this issue Sep 16, 2021
The dom lib inserts all dom related types into the project, which is often
undesirable when working on a NodeJS project.

This change injects global stubs for the dom types required by puppeteer, so
puppeteer can work without users having to add dom types to their project.

Closes puppeteer#6989
This was referenced May 30, 2022
This was referenced May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment