Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolution error when using TypeScript with moduleResolution set to node16 or nodenext #669

Closed
wojtekmaj opened this issue Feb 12, 2024 · 3 comments
Assignees
Labels

Comments

@wojtekmaj
Copy link

wojtekmaj commented Feb 12, 2024

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

@remarkablemark
Copy link
Owner

@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

Screen Shot 2024-02-12 at 1 21 59 PM

@wojtekmaj
Copy link
Author

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';

remarkablemark added a commit that referenced this issue Feb 12, 2024
@remarkablemark
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants