@@ -12,6 +12,7 @@ type OmitByValue<T, Value> = {
12
12
[ P in keyof T as T [ P ] extends Value ? never : P ] : T [ P ] ;
13
13
} ;
14
14
type StringToBoolean < T > = T extends 'true' | 'false' ? boolean : T ;
15
+ export type Simplify < T > = { [ KeyType in keyof T ] : T [ KeyType ] } ;
15
16
16
17
export type ClassNameValue = string | null | undefined | ClassNameValue [ ] ;
17
18
@@ -31,12 +32,14 @@ export type ClassNameValue = string | null | undefined | ClassNameValue[];
31
32
*/
32
33
export type VariantsSchema = Record < string , Record < string , ClassNameValue > > ;
33
34
34
- export interface VariantsConfig < V extends VariantsSchema > {
35
+ export type VariantsConfig < V extends VariantsSchema > = {
35
36
base ?: ClassNameValue ;
36
37
variants ?: V ;
37
- defaultVariants ?: keyof V extends never ? never : Partial < Variants < V > > ;
38
- compoundVariants ?: keyof V extends never ? never : CompoundVariant < V > [ ] ;
39
- }
38
+ defaultVariants ?: keyof V extends never
39
+ ? Record < string , never >
40
+ : Partial < Variants < V > > ;
41
+ compoundVariants ?: keyof V extends never ? never [ ] : CompoundVariant < V > [ ] ;
42
+ } ;
40
43
41
44
/**
42
45
* Rules for class names that are applied for certain variant combinations.
@@ -109,7 +112,7 @@ type VariantsHandlerFn<P> = PickRequiredKeys<P> extends never
109
112
export function variants <
110
113
C extends VariantsConfig < V > ,
111
114
V extends VariantsSchema = NonNullable < C [ 'variants' ] >
112
- > ( config : C ) {
115
+ > ( config : Simplify < C > ) {
113
116
const { base, variants, compoundVariants, defaultVariants } = config ;
114
117
115
118
if ( ! ( 'variants' in config ) || ! config . variants ) {
@@ -118,7 +121,7 @@ export function variants<
118
121
}
119
122
120
123
function isBooleanVariant ( name : keyof V ) {
121
- const variant = variants ?. [ name ] ;
124
+ const variant = ( variants as V ) ?. [ name ] ;
122
125
return variant && ( 'false' in variant || 'true' in variant ) ;
123
126
}
124
127
0 commit comments