Closed iremlopsum closed 4 years ago
Hey guys,
Often times I want to do something like
const styles = StyleSheet.create({ square: (size: number) => ({ width: size, height: size, }), })
Now this doesn't work, because I get Type '(size: number) => { width: number; height: number; }' is not assignable to type 'ViewStyle | TextStyle | ImageStyle'. I've tried doing things like
Type '(size: number) => { width: number; height: number; }' is not assignable to type 'ViewStyle | TextStyle | ImageStyle'.
interface Style { square: (width: number) => ViewStyle } const styles = StyleSheet.create<Style>({ square: (size: number) => ({ width: size, height: size, }), })
But then I get Type 'Style' does not satisfy the constraint 'NamedStyles<any> | NamedStyles<Style>'.
Type 'Style' does not satisfy the constraint 'NamedStyles<any> | NamedStyles<Style>'.
Any ideas how to deal with this?
You should probably take this to stack overflow 👍
Hey guys,
Often times I want to do something like
Now this doesn't work, because I get
Type '(size: number) => { width: number; height: number; }' is not assignable to type 'ViewStyle | TextStyle | ImageStyle'.
I've tried doing things likeBut then I get
Type 'Style' does not satisfy the constraint 'NamedStyles<any> | NamedStyles<Style>'.
Any ideas how to deal with this?