Skip to content

fix(types): type element lists as tag name strings - #671

Merged
cossssmin merged 1 commit into
masterfrom
fix/element-list-types
Sep 24, 2026
Merged

cossssmin merged 1 commit into
masterfrom
fix/element-list-types

Conversation

@cossssmin

Copy link
Copy Markdown
Collaborator

Closes #389

heightElements, widthElements, tableElements and nonVisualElements were typed as HTMLElement[], which caused two problems:

  • in Node projects without the dom lib, index.d.ts didn't compile at all (Cannot find name 'HTMLElement')
  • even with dom, the type was wrong: at runtime these are upper-case tag names like ['TABLE', 'TD', 'TH', 'IMG'], so something like juice.widthElements = ['IMG', 'VIDEO'] was a type error and needed a cast

They're now string[], with a short doc comment noting the names are upper-case (that's how Juice compares them).

To keep DOM types from sneaking back in, the TypeScript test now runs without the dom lib (lib: ["ES2022"], types: ["node"]) and with skipLibCheck: false. With the old types it failed with exactly the four errors from the issue. It also assigns and reads all four lists as strings.

Heads-up for anyone who worked around this with a cast like as unknown as HTMLElement[]: that cast is now a type error, just remove it.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@cossssmin
cossssmin merged commit 4e3426f into master Sep 24, 2026
3 checks passed
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

Successfully merging this pull request may close these issues.

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

1 participant