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

Avoid forcing TS DOM library #1746

Open
CarsonF opened this issue Oct 22, 2024 · 0 comments
Open

Avoid forcing TS DOM library #1746

CarsonF opened this issue Oct 22, 2024 · 0 comments

Comments

@CarsonF
Copy link

CarsonF commented Oct 22, 2024

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':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant