Description
The cva, sva recipe functions currently infer both variants and the css of each variant. I would like them to only infer variant names and their values because the inferred css can be quite large.
Problem Statement/Justification
I propose this because of the following issues I've noticed when using cva/sva:
- In a library with the declaration setting on, I run into the typescript error:
The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.ts(7056) when trying to reuse styles across multiple variants in a recipe (example).
- Type errors in the variants object are not reported where they occur, rather at the
variants property. This makes it hard to debug large recipes (example).
- It's possible to specify incorrect/nonexistent properties in the variants object (example).
Proposed Solution or API
I would like to suggest looser inference in the inferred variant type in cva and sva as shown in the following files:
- cva. The main change for cva is at this line
- sva. The main change for sva is at this line.
I'm not sure if these types are performant, but I hope this creates a starting point for limiting inference there.
Alternatives
For the max serialisation length error, I have tried using satisfies instead of directly setting the type of the shared styles to SystemStyleObject, but that seems a bit unintuitive.
i.e:
const shared = {} satisfies SystemStyleObject;
// instead of
const shared: SystemStyleObject = {}
Additional Information
No response
Description
The
cva,svarecipe functions currently infer both variants and the css of each variant. I would like them to only infer variant names and their values because the inferred css can be quite large.Problem Statement/Justification
I propose this because of the following issues I've noticed when using cva/sva:
The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.ts(7056)when trying to reuse styles across multiple variants in a recipe (example).variantsproperty. This makes it hard to debug large recipes (example).Proposed Solution or API
I would like to suggest looser inference in the inferred variant type in cva and sva as shown in the following files:
I'm not sure if these types are performant, but I hope this creates a starting point for limiting inference there.
Alternatives
For the max serialisation length error, I have tried using
satisfiesinstead of directly setting the type of the shared styles toSystemStyleObject, but that seems a bit unintuitive.i.e:
Additional Information
No response