Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Hello 👋,
I'm building a guide on how to build a Vue.js component library (https://x.com/soubiran_/status/1860643319308583164) and I'm using Tailwind Variants to show how to organize a component.
Everything was fine until I exported the component.
Here the Button component:
In a Vue file, everything works fine. Then, I transpile the component with Vite. Everything works fine too.
Here the types transpiled component (Button.vue.d.ts):
But there is an issue here with
import('tailwind-variants/dist/config').TVConfig
. TypeScript is unable to know what isTVConfig
, eventailwind-variants/dist/config
is completely unknown.The result is an untyped
ButtonVariantProps
:Which is not what I want.
To fix this, the
dist/
folder need to explicitly export its types. I also change the exports order since the types must always be the first exports and the default export, CJS in this case, must be the last export.Reference: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package.json-exports-imports-and-self-referencing:~:text=Note%20that%20the%20%22types%22%20condition%20should%20always%20come%20first%20in%20%22exports%22.
I try the fix with the following patch:
And everything works fine. 🙌
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).