Avoid forcing TS DOM library
- Dominant language
- TypeScript
- Stars
- 199
- Forks
- 36
- Avg merge
- 5h 40m
- Merged PRs (30d)
- 58
Description
**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?
```json
{
"exports": {
"node": {
"types": "./node.d.ts",
},
}
}
```
```ts
// ./node.d.ts
///
export * from './common.d.ts':
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by inspecting the triple-slash references at packages/fetch/dist/index.d.ts#L1-L2 and the package.json exports configuration. Compare the Node and browser typing requirements described in the issue, then verify that Node consumers no longer receive DOM globals while browser consumers retain the necessary types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100