-
Notifications
You must be signed in to change notification settings - Fork 310
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
StyleXStyles in typescript library component #760
Comments
All your code examples look correct. Could you, by any chance, help me with a small project where you can reproduce this issue? I tried to verify these types and they all work correctly on my end. There is a high likelihood that the problem is specific to creating a library and using Outside of this, I have a PR up with some type improvements which should be merged and released this week. Try version Also, we recommend using |
https://github.com/GCoboFacePhi/styleX-tsup-design-system Here is a quick example. In In In The goal of this example repository is to update the official documentation by adding this example, creating a real component library.
|
Describe the issue
I am changing the styles from @stitches/react to StyleX. In a component I am adding a prop which is className to which I am adding the StyleXStyles type, as it comes in the documentation and in the nextjs-example itself. But when I do the build ( I use Tsup ) it is failing me.
Im using v0.8.0
Expected behavior
Correct type
Steps to reproduce
And className prop has this error
Argument of type '(Readonly<Readonly<{ readonly theme?: StyleXClassNameFor<"theme", Readonly<string | null | undefined>> | undefined; readonly MozOsxFontSmoothing?: StyleXClassNameFor<"MozOsxFontSmoothing", Readonly<...>> | undefined; ... 527 more ...; readonly '::-webkit-search-results-decoration'?: StyleXClassNameFor<...> | undefin...' is not assignable to parameter of type 'StyleXArray<boolean | CompiledStyles | readonly [CompiledStyles, unique symbol] | null | undefined>'.
To avoid this error i have to change the type to this
Once the type is changed, I am implementing this component in a nextjs app and I am adding a style to it.
but the prop className still fails
Type 'Readonly<{ readonly color: StyleXClassNameFor<"color", "white">; readonly backgroundColor: StyleXClassNameFor<"backgroundColor", "red" | "blue">; }>' is not assignable to type 'StyleXArray<boolean | CompiledStyles | readonly [CompiledStyles, unique symbol]> & string'. Type 'Readonly<{ readonly color: StyleXClassNameFor<"color", "white">; readonly backgroundColor: StyleXClassNameFor<"backgroundColor", "red" | "blue">; }>' is not assignable to type 'Readonly<{ [key: string]: void | StyleXClassName; }> & string'. Type 'Readonly<{ readonly color: StyleXClassNameFor<"color", "white">; readonly backgroundColor: StyleXClassNameFor<"backgroundColor", "red" | "blue">; }>' is not assignable to type 'string'
Test case
No response
Additional comments
No response
The text was updated successfully, but these errors were encountered: