juice icon indicating copy to clipboard operation
juice copied to clipboard

Dom types not usable in nodejs (Cannot find name 'HTMLElement')

Open pxDot opened this issue 4 years ago • 3 comments

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?

pxDot avatar Nov 12 '21 16:11 pxDot

Same here. I didn't want to include dom either, so I worked around this for now:

 declare type HTMLElement = never;

qqilihq avatar Feb 16 '22 13:02 qqilihq

Same here. I didn't want to include dom either, so I worked around this for now:

 declare type HTMLElement = never;

I am also facing the same issue.

@qqilihq Where to add this type?

did you patch the package?

SMKH-PRO avatar Oct 26 '22 14:10 SMKH-PRO

@SMKH-PRO I added it in a global typing file in my project afair. Definitely no patching needed.

qqilihq avatar Oct 26 '22 20:10 qqilihq