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

htmlparser2 major version update causes issues with Typescript #601

Open
perezal opened this issue Jan 11, 2023 · 6 comments
Open

htmlparser2 major version update causes issues with Typescript #601

perezal opened this issue Jan 11, 2023 · 6 comments

Comments

@perezal
Copy link

perezal commented Jan 11, 2023

A minor version update to sanitize-html included a major version update to htmlparser2, causing build issues with Typescript v4.2.4. Temporarily fixed by locking sanitize-html version at 4.2.0, but I wonder if minor version updates should include changes that aren't backwards compatible?

To Reproduce

Step by step instructions to reproduce the behavior:

  1. Use sanitize-html with Typescript v4.2.4
  2. Attempt to build

Expected behavior

It builds successfully.

Describe the bug

The major version upgrade to htmlparser2 causes build issue TS1005 with older minor versions of Typescript (using 4.2.4 vs 4.9.4 latest). Should minor version increments include major version dependency updates?

Details

Version of Node.js:
Node v16.19.0

Server Operating System:
MacOS X Monterey 12.6.1, also presents the same issue in Docker v20.10.11 using node:16-buster

@boutell
Copy link
Member

boutell commented Jan 12, 2023

Typescript support for this module is community maintained, we do not use Typescript in-house and are not really in a position to test and maintain that. So my question is whether the typings file just needs to be updated by interested community members in some way or if there is a larger issue with the latest version of htmlparser2. But to my knowledge there is no reason why compiling a javascript (not typescript) submodule should bother Typescript at all.

@arcreative
Copy link

I've had the same issue. Very concerning that a minor version upgrade could cause this, as it was quite hard to track down...

@boutell
Copy link
Member

boutell commented Oct 30, 2023

What is the issue, exactly? Where in the sanitize-html API is it exposed? Thanks.

@dylanarmstrong
Copy link
Contributor

@boutell, It's an issue when using sanitize-html with typescript < 4.5. The htmlparser2 types are not supported on typescript versions that low: https://github.com/fb55/htmlparser2/releases/tag/v8.0.0

I'm not really sure there's anything that can be done here aside from locking the sanitize-html version to one that doesn't include this version.

@boutell
Copy link
Member

boutell commented Feb 22, 2024 via email

@dylanarmstrong
Copy link
Contributor

I wasn't able to find anyway to do this that actually worked. Tested a couple ideas on both @types and the sanitize-html package. I think specifying in the README that typescript has to be >= 4.5 is only solution. The types for sanitize-html have a dependency on htmlparser2 types for ParserOptions for the parser method.
PR for README here: https://github.com/apostrophecms/sanitize-html/pull/655/files

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

No branches or pull requests

4 participants