Skip to content

Avoid forcing TS DOM library #1746

@CarsonF

Description

@CarsonF

Is your feature request related to a problem? Please describe.

This library implicitly pulls in the dom library to my application.
https://github.com/ardatan/whatwg-node/blob/master/packages/fetch/dist/index.d.ts#L1-L2

Because it's a triple slash reference, it just happens, and I have no way of controlling this on my side.
Now my nodejs API has dom types available, which is annoying and error prone.
I shouldn't be able to access window for a contrived example.

I was able to patch out these two lines on my side.
Everything still works for me, as the (latest?) @types/node provide all of these types.

Describe the solution you'd like

Unfortunately I don't have a good solution to propose. I get that you don't want to depend on @types/node and dom library reference makes sense when you are in a browser.

Maybe a separate types file can be targeted using package.json exports?

{
  "exports": {
    "node": {
      "types": "./node.d.ts",
    },
  }
}
// ./node.d.ts

/// <reference types="node" />

export * from './common.d.ts':

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