Automattic / juice

Juice inlines CSS stylesheets into your HTML source.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

squareloop1 opened this issue · 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?

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

 declare type HTMLElement = never;

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 I added it in a global typing file in my project afair. Definitely no patching needed.