-
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:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 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. |
Beta Was this translation helpful? Give feedback.
-
I have the same issue, but using here is my
my
and this is the relevant part of
|
Beta Was this translation helpful? Give feedback.
-
I used the import of the separate type of the import type { VariantProps } from 'class-variance-authority'; It's working for me. |
Beta Was this translation helpful? Give feedback.
-
I migrated to the new major version and it solved the problem. It is in beta now, however I didn't get any issues |
Beta Was this translation helpful? Give feedback.
Ok it was a problem with
moduleResolution
in 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.