joe-bell / cva

Class Variance Authority
https://cva.style
Apache License 2.0
5.66k stars 109 forks source link

Not compatible with the latest 5.x release of TypeScript #125

Closed zkanda closed 1 year ago

zkanda commented 1 year ago

I'm getting a dependency resolution error on the latest tagged version. Perhaps the project wanna release a new version.

~/c/z/project-app ❯❯❯ npm install class-variance-authority                                                                                                                                             ✘ 1 main ✱
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: class-variance-authority@0.4.0
npm ERR! Found: typescript@5.0.2
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@">=3.3.1" from eslint-config-next@13.2.4
npm ERR!   node_modules/eslint-config-next
npm ERR!     eslint-config-next@"13.2.4" from the root project
npm ERR!   peer typescript@">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" from tsutils@3.21.0
npm ERR!   node_modules/tsutils
npm ERR!     tsutils@"^3.21.0" from @typescript-eslint/typescript-estree@5.55.0
npm ERR!     node_modules/@typescript-eslint/typescript-estree
npm ERR!       @typescript-eslint/typescript-estree@"5.55.0" from @typescript-eslint/parser@5.55.0
npm ERR!       node_modules/@typescript-eslint/parser
npm ERR!         @typescript-eslint/parser@"^5.42.0" from eslint-config-next@13.2.4
npm ERR!         node_modules/eslint-config-next
npm ERR!   2 more (the root project, ts-node)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@">= 4.5.5 < 5" from class-variance-authority@0.4.0
npm ERR! node_modules/class-variance-authority
npm ERR!   class-variance-authority@"0.4.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@4.9.5
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@">= 4.5.5 < 5" from class-variance-authority@0.4.0
npm ERR!   node_modules/class-variance-authority
npm ERR!     class-variance-authority@"0.4.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/zkanda/.npm/_logs/2023-03-17T06_53_53_092Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/zkanda/.npm/_logs/2023-03-17T06_53_53_092Z-debug-0.log

Thanks for this amazing project.

hugo-vrijswijk commented 1 year ago

I'm wondering why TypeScript is a peerDependency at all. Libraries shouldn't have it as a dependency if it's only used for building (and not doing anything with the actual ts compiler)

Gravy59 commented 1 year ago

I'm wondering why TypeScript is a peerDependency at all. Libraries shouldn't have it as a dependency if it's only used for building (and not doing anything with the actual ts compiler)

I think it has to do with the fact that CVA is designed for TS, but there are always those who can't (or won't) use TS and still want to use CVA.

Mejiabrayan commented 1 year ago

Beat me to it. Also having the same issue 😭

hugo-vrijswijk commented 1 year ago

I think it has to do with the fact that CVA is designed for TS, but there are always those who can't (or won't) use TS and still want to use CVA.

For those cases simply publishing the type declarations is enough. There's no need for TypeScript to be a peer dependency if all you're doing is publishing types

joe-bell commented 1 year ago

Hey gang!

Appreciate the enthusiasm to get the ball rolling on this, but I'm in strict vacation mode right now until mid-April.

I've been coding flat-out over the last year for work and during my free time – I don't get paid for my open-source work. (I can't use GitHub Sponsors due to lack of taxation features outside of the US)


Quickly dropping in to answer the burning question:

I'm wondering why TypeScript is a peerDependency at all. Libraries shouldn't have it as a dependency if it's only used for building (and not doing anything with the actual ts compiler)

It's here to make sure that people using CVA with TypeScript are using a supported version (I would much rather close https://github.com/joe-bell/cva/pull/127 in favour of a simple version bump to continue that trend)


Rest assured this will be fixed, and I'll tackle it as soon as I'm back from vacation. In the meantime I'd be grateful for a few weeks of patience 🙏

If you need a workaround in the meantime, check out options like pnpm patch

domnantas commented 1 year ago

It's a bit of a 🐥 and the 🥚 problem – it is impossible to work around it with pnpm patch or npx patch-package. Patches are only applied in postinstall, so it's too late because the error happens during the install. It is not possible to run patch-package on preinstall either, because patch-package and cva is not installed yet https://github.com/ds300/patch-package/issues/49#issuecomment-831231339

Not sure if there are any possible workarounds besides forking, downgrading TS, or using npm install --force locally and on CI for the time being. Totally understand you are on vacation and I wish you a good rest, I'm just surprised there are no mechanisms in JS to work around this 😅

joe-bell commented 1 year ago

Shipped in 0.5.1 :ship:


I'm still supposed to be on vacation right now, so please consider supporting the project if this release is useful to you!