Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error on build after upgrading to v0.2 #181

Open
josantana opened this issue Apr 8, 2024 · 1 comment
Open

Type error on build after upgrading to v0.2 #181

josantana opened this issue Apr 8, 2024 · 1 comment
Labels
bug Something isn't working need info Further information is requested

Comments

@josantana
Copy link

Describe the bug
After upgrading to v0.2.1, I got the following error message when trying to build some of the components I'm developing:

error TS2742: The inferred type of 'buttonStyles' cannot be named without a reference to '.pnpm/tailwind-merge@2.2.2/node_modules/tailwind-merge'. This is likely not portable. A type annotation is necessary.
error TS2742: The inferred type of 'buttonStyles' cannot be named without a reference to '@/components/button/node_modules/tailwind-variants/dist/config'. This is likely not portable. A type annotation is necessary.
error TS2742: The inferred type of 'buttonStyles' cannot be named without a reference to '@/components/button/node_modules/tailwind-variants/dist'. This is likely not portable. A type annotation is necessary.

These three messages repeats several times when I run the build command.

To Reproduce
Here it is my scenario:

// From packages/components/button.styles.tsx
import { tv } from "tailwind-variants";
export const buttonStyles = tv({ slots: { base: "..." }, ... });

// From packages/components/pagination.tsx
import { buttonStyles } from "@/components/button/button.styles";

const { base } = buttonStyles({ ... });

Above, I'm importing the Button styles to reuse on the Pagination component. That's what started it all. After that, I got some inconsistent build behavior even from the simple usage of tv inside a single package. The error occurs when tsup is building DTS files.

I'm working on a monorepo, using PNPM as package manager and tsup to build the package. I've tried to clean up PNPM's cache and tweak some tsconfig configs, with no success. The only stable solution I got was to rollback Tailwind Variants to v0.1.2.

This is likely related to the move to Tailwind Merge 2.2.0 on version ^0.2. But I'm not certain exactly why.

Expected behavior
Expected it to just work, like it did on version ^0.1 so I can keep my project up-to-date with its dependencies.

@josantana josantana added the bug Something isn't working label Apr 8, 2024
@mskelton
Copy link
Collaborator

@josantana Do you have tailwind-merge installed in your project separately from tailwind-variants?

@mskelton mskelton added the need info Further information is requested label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need info Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants