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

Module '"../@types/domhandler"' has no exported member #231

Closed
fabienbranchel opened this issue Feb 24, 2021 · 7 comments · Fixed by #240
Closed

Module '"../@types/domhandler"' has no exported member #231

fabienbranchel opened this issue Feb 24, 2021 · 7 comments · Fixed by #240
Labels
bug Something isn't working

Comments

@fabienbranchel
Copy link

fabienbranchel commented Feb 24, 2021

Expected Behavior

Run OK

Actual Behavior

Run KO

Steps to Reproduce

When used with TypeScript (4.1.5), it's suggest to install @types/domhandler and @types/htmlparser2.

It's fine. But when it's done, I've got these errors :

image

Environment

  • Version: 1.2.4
  • Platform: macOS
  • Browser: Chrome
@remarkablemark
Copy link
Owner

remarkablemark commented Feb 26, 2021

@fabienbranchel can you import the types without using @types?

import { Comment, ProcessingInstruction, Text } from 'html-react-parser';

See index.d.ts.

@remarkablemark remarkablemark added the question Further information is requested label Feb 26, 2021
@fabienbranchel
Copy link
Author

fabienbranchel commented Feb 26, 2021

I tried, it's not resolving the issue.
Moreover, it's doesn't feel right to import something I don't use directly.

@remarkablemark
Copy link
Owner

So domhandler exports its own types so installing @types/domhandler may be unnecessary.

Can you provide a reproducible example using CodeSandbox?

@kfritsch
Copy link
Contributor

Fix

Hey I got the same Issue. I think the fix would be adding domhandler ^4.0.0 as a dependency.

Explanation

The problem seems to be that this package uses "domhandler" directly but does not have it as a direct dependency. It only has it as an indirect dependency via "html-dom-parser". This can cause problems with the way npm installs packages. If another package requires an older version of "domhandler" and is installed first it will be placed at the root level of node_modules. Since this package does not have an explicit dependency on "domhandler" it will use what is installed at the root level. That "html-dom-parser" uses the required newer version does not help since this version is now placed inside "html-dom-parser".

  • /node_modules
    • /domhandler (v3.0.0)
    • /html-dom-parser
      • /domhandler (v.4.0.0)
    • /html-react-parser

Workaround

The installation of the old "domhandler" 3.0.0 is actually triggered by the dependencies of this module. This means that the only other workaround would be adding "domhandler" ^4.0.0 before "html-react-parser" in the dependencies so it ends up at the root level.

kfritsch added a commit to kfritsch/html-react-parser that referenced this issue Apr 12, 2021
added missing dependency for "domhandler": "^4.0.0"
@remarkablemark
Copy link
Owner

@kfritsch Thanks for opening the PR. I left some comments.

@remarkablemark remarkablemark added bug Something isn't working and removed question Further information is requested labels Apr 12, 2021
@remarkablemark
Copy link
Owner

remarkablemark commented Apr 12, 2021

@fabienbranchel @kfritsch I'll make a release later tonight for #240

@remarkablemark
Copy link
Owner

Published v1.2.5:

npm:

Yarn:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants