Skip to content

since htmlparser2@8 type declaration requires ts >= 4.5 #1242

@olivier-martin-sf

Description

@olivier-martin-sf

It looks like since #1165 landed in the repo, the bundled type declarations use mixed exports (exporting both type and values) which was introduced in TS 4.5 AFAIK.

I am wondering if there's an assumption that the consumer of the package runs a specific version of TS since the htmlparser2@v8.X.X release line. I tried to use that library in a project that runs under TS 4.2 and the type checker errors out as it doesn't understand the mixed exports syntax. That's the kind of error that are being thrown:

node_modules/htmlparser2/lib/index.d.ts:2:23 - error TS1005: ',' expected.

2 export { Parser, type ParserOptions };
                        ~~~~~~~~~~~~~

Maybe we could add a note about the minimum TS requirement or provide backward compatible type declarations (relying on typesVersion and using a tool such as downlevel-dts).

Thank you so much for your work on this awesome lib and hopefully this is useful feedback

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions