When attempting to use variables in my StyleSheet file, I encounter a type error even though the UI works fine. Any suggestions on how to resolve this issue?
type buttonStyle = (height: number, width: string, color: string) => ViewStyle;
export type Styles = {
button: buttonStyle;
};
export default StyleSheet.create<Styles>({
button: (height: number, width: string, color: string) => ({
height: height,
width: width,
backgroundColor: color,
alignItems: 'center',
justifyContent: 'center',
borderRadius: 10,
}),
});
The error message related to types is as follows:
Type 'Styles' does not satisfy the constraint 'NamedStyles<any> | NamedStyles<Styles>'.
Type 'Styles' is not assignable to type 'NamedStyles<Styles>'.
Types of property 'button' are incompatible.
Type 'buttonStyle' is not assignable to type 'ViewStyle | TextStyle | ImageStyle