Skip to content

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

Closed
@remcohaszing

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions