Repository navigation
|
Hi, I have built a component library with React, Vite, TailwindCSS and Class Variance Authority (CVA) and Typescript. Importing components in a consumer projects works as expected. However, the props for variants (provided by CVA) do not work. They appear in the compiled .d.ts files, but do not work when I use the components. The main problem I see when i generate the definition file (xxx.d.ts) is that the
This is generated like that: Instead of: When I do a build in the project, the dist is correctly generated and the VariantProps is working propperly, but when I use this project as a dependency of another, the (xxx.d.ts) file shows the first code that I show with the [xxx]: any. Here it is my tsconfig.json and the related part of my package.json: |
Replies: 4 comments 10 replies
|
Ok it was a problem with If you put moduleResolution to "Bundler" and execute "yarn build", the generated type definition file (xxx.d.ts) has the correct path for "ClassProp" from "cva", but not the consumer projects. If you put moduleResolution to "node", you will see the ClassProp import path generated on dist/xxx.d.ts to change and give error on the library project, but not on the consumer projects. Hope this helps to anyone who is facing the same problmem. |
|
I have the same issue, but using here is my my and this is the relevant part of |
|
I used the import of the separate type of the import type { VariantProps } from 'class-variance-authority';It's working for me. |
|
I migrated to the new major version and it solved the problem. It is in beta now, however I didn't get any issues |
Ok it was a problem with
moduleResolutionin tsconfig file.If you put moduleResolution to "Bundler" and execute "yarn build", the generated type definition file (xxx.d.ts) has the correct path for "ClassProp" from "cva", but not the consumer projects.
If you put moduleResolution to "node", you will see the ClassProp import path generated on dist/xxx.d.ts to change and give error on the library project, but not on the consumer projects.
Hope this helps to anyone who is facing the same problmem.