Resolution error when using TypeScript with `moduleResolution` set to `node16` or `nodenext`
wojtekmaj opened this issue · 3 comments
Expected Behavior
html-dom-parser to resolve correctly when using TypeScript with moduleResolution set to node16 or nodenext (effectively: in pure ESM environment).
Actual Behavior
html-dom-parser is not resolved correctly:
https://arethetypeswrong.github.io/?p=html-dom-parser%405.0.7
This also causes the types to be non-functional in VSCode.
Steps to Reproduce
Create a project using TypeScript with moduleResolution set to node16 or nodenext.
Create a file with the following content:
import htmlToDOM from 'html-dom-parser';you'll already see, when you hover over htmlToDOM bit, that types are not loaded correctly.
Reproducible Demo
Environment
- Version: 5.1.2
- Platform: Node.js
- Browser: not applicable
- OS: macOS Sonoma 14.2.1
Keywords
Relates to remarkablemark/html-react-parser#1305
@wojtekmaj I created a test repo following your steps to reproduce and did not see any TS errors in VSCode: https://github.com/remarkablemark/html-dom-parser-esm-demo
Hey, apologies - too much copy and paste :D It's still the same problem as with html-react-parser, but symptoms are indeed slightly different.
Default export is indeed fine, as extension is specified. But importing types doesn't work:
import type { Comment, Element, ProcessingInstruction, Text, DOMNode } from 'html-dom-parser';Release:
