Dom types not usable in nodejs (Cannot find name 'HTMLElement')
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 233
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 8
Description
In backend nodejs projects the DOM types (`HTMLElement`) are only accessible if included explicitly by e.g. `"lib": ["ES2020", "dom"]` in tsconfig. Building without the included dom types gives the following error:
```
node_modules/juice/juice.d.ts:27:36 - error TS2304: Cannot find name 'HTMLElement'.
27 export let heightElements: HTMLElement[];
~~~~~~~~~~~
node_modules/juice/juice.d.ts:29:39 - error TS2304: Cannot find name 'HTMLElement'.
29 export let nonVisualElements: HTMLElement[];
~~~~~~~~~~~
node_modules/juice/juice.d.ts:31:35 - error TS2304: Cannot find name 'HTMLElement'.
31 export let tableElements: HTMLElement[];
~~~~~~~~~~~
node_modules/juice/juice.d.ts:32:35 - error TS2304: Cannot find name 'HTMLElement'.
32 export let widthElements: HTMLElement[];
```
Including all of the dom types only for the `HTMLElement` type seems like a bad idea and introducing alot of bloat.
Is there any workaround or possibility for another usable type here?
Contributor guide
Research direction
The reported declarations are in node_modules/juice/juice.d.ts; first reproduce the TypeScript error with a Node tsconfig that omits dom. Trace how the HTMLElement exports are typed, then verify that a supported declaration lets the same configuration compile without requiring the full DOM library.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100