Closed ben-laird closed 8 months ago
@ben-laird is attempting to deploy a commit to the cva Team on Vercel.
A member of the Team first needs to authorize it.
Appreciate the PR, but these types have been completely rewritten already in cva@beta
:
https://github.com/joe-bell/cva/blob/main/packages/cva/src/index.ts
Feel free to raise your suggestions there, but I don't intend to develop further on the class-variance-authority
package
Thanks so much for the suggestion, I'll take a look there too. I'd still want to merge this PR as it's just a patch/bug fix that improves types DX, but I don't want to presume. Thanks again for the feedback, I'll contribute to/use the beta version.
I'll close this for now, but keep me posted on how you get on with the beta? 🙏
Description
This PR intends to fine-tune the types surrounding the main
cva
function following a small problem I encountered when using cva in a different project.Additional context
My contribution is entirely within
packages/class-variance-authority/src/index.ts
. TheConfig<T>
type didn't properly constrain the type parameter, instead using a type ternary to evaluate tonever
whenT
didn't extendConfigSchema
:In doing so, the second parameter in
cva
would often complain that the type of its argument is not assignable toundefined
, essentiallyundefined | never
. I didn't know how to fix that because I had to follow a type I couldn't introspect very well in order to introspect/know the type (ie have autocomplete, etc). I simply moved the extension constraint to the type parameter instead of in a type ternary:What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).