Skip to content

The current types include globals that don't exist in Node #145

@Elarcis

Description

@Elarcis

xpath.d.ts has a /// <reference lib="dom" /> directive, which makes the whole DOM API available to any TypeScript project that imports xpath, even though it does not need the DOM to function.

In my Node project, my types are now getting all mixed up because TypeScript imported the DOM types and made them available in the whole project, creating conflicts for Document, setTimeout, clearTimeout etc. No need to tell you this is a huge hit in code quality and safety.

@xmldom/xmldom had the exact same issue, which they fixed last autumn: xmldom/xmldom#285

I think their modus operandi was to basically extract the definitions from TypeScript’s lib.dom.d.ts.

Should this package reuse @xmldom/xmldom’s interfaces to not depend on the DOM, or have a similar approach?

EDIT: I just checked your package.json and @xmldom/xmldom is already listed as a dev dependency, to me it would make sense to use their types (Document, Node), etc. rather than lib.dom.d.ts’s.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions