natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
990 stars 57 forks source link

depedency @iconify/tools v3 comes with incorrect types for cheerio (fixed in v4) #210

Open aripalo opened 3 months ago

aripalo commented 3 months ago

What version of astro-icon are you using?

v1.1.0

Astro Info

Astro                    v4.4.11
Node                     v20.11.1
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         astro-icon

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Not directly a bug in astro-icon, but a bug that has been fixed in astro-icon's depedencies.

@iconify/tools had an issue (that is fixed now) where it installed @type/cheerio package even though cheerio@1.0.0-rc.12 (which it uses) comes with its own (correct) type definitions.

You can see the transitive dependency of @types/cheerio in astro-icon's pnpm-lock.yaml.

When using cheerio@1.0.0-rc.12 in one's own codebase, this can lead to type errors as TypeScript is incorrectly resolving the types from @types/cheerio (and not the cheerio package itself).

I acknowledge that the fix would require a major version bump for @iconify/tools from v3 to v4, so this might require more work than just version bump, but I still feel this is an issue worth mentioning (and creating an issue for).

What's the expected result?

We'll I'd like astro-icon to bump up its depedency of @iconify/tools from v3 to v4, so that one wouldn't have to deal with the incorrect @types/cheerio.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-8hrtln?file=src%2Fdemo.ts

aripalo commented 3 months ago

In case someone else has this problem, one hacky-workaround could be configuring this into package.json:

"overrides": {
  "@iconify/tools": {
    "@types/cheerio": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz"
    }
 },

Package.json overrides allow to override the version of any dependency, but as npm accepts tgz url as version, I'm pointing it to the cheerio package instead.