40
40
// }
41
41
// });
42
42
43
- import { ImageStyle , TextStyle , ViewStyle , DimensionValue } from 'react-native' ;
43
+ import { ImageStyle , TextStyle , ViewStyle , StyleProp } from 'react-native' ;
44
44
45
- type TokenString = `$${string } `;
45
+ // Define a type that removes token strings from style properties
46
+ type ResolvedStyle = ViewStyle & TextStyle & ImageStyle ;
46
47
47
- export type StyleObject = Partial < {
48
- [ K in keyof ( ViewStyle & TextStyle & ImageStyle ) ] :
49
- | ( ViewStyle & TextStyle & ImageStyle ) [ K ]
50
- | ( K extends keyof ViewStyle ? TokenString | DimensionValue : TokenString ) ;
51
- } > ;
48
+ // StyleObject now extends ResolvedStyle
49
+ type StyleObject = {
50
+ [ K in keyof ResolvedStyle ] ?:
51
+ | ResolvedStyle [ K ]
52
+ | ( string extends ResolvedStyle [ K ] ? `$${string } ` : never )
53
+ | ( number extends ResolvedStyle [ K ] ? `$${string } ` : never ) ;
54
+ } ;
52
55
53
56
// Define the VariantOptions type to ensure type safety in variant definitions
54
57
type VariantOptions < V > = {
@@ -98,7 +101,7 @@ export function styles<V extends VariantOptions<V>>(config: VariantStyleConfig<V
98
101
type DefaultProps = NonNullable < typeof config . defaultVariants > ;
99
102
type Props = OptionalIfHasDefault < VariantProps , DefaultProps > ;
100
103
101
- return ( props ?: Props ) => {
104
+ return ( props ?: Props ) : StyleProp < ResolvedStyle > => {
102
105
// Start with base styles
103
106
let styles : StyleObject = {
104
107
...( config . base || { } ) ,
@@ -140,7 +143,7 @@ export function styles<V extends VariantOptions<V>>(config: VariantStyleConfig<V
140
143
}
141
144
}
142
145
143
- return styles ;
146
+ return styles as StyleProp < ResolvedStyle > ;
144
147
} ;
145
148
}
146
149
@@ -154,8 +157,6 @@ interface AllowedTokenCategories {
154
157
fontSizes : number ;
155
158
fonts : string ;
156
159
lineHeight : number ;
157
- borderWidth : number ;
158
- borderStyles : 'solid' | 'dashed' | 'dotted' | 'none' ;
159
160
}
160
161
161
162
// Update TokenConfig to only allow specific categories
0 commit comments