react-native-themed-styles
react-native-themed-styles copied to clipboard
NamedStyles typing error with Image component
Hi here 👋
When using a themed style with an Image component I got this error from TS:
Overload 1 of 2, '(props: Readonly<ImageProps>): Image', gave the following error.
Type 'ViewStyle | TextStyle | ImageStyle' is not assignable to type 'StyleProp<ImageStyle>'.
Type 'ViewStyle' is not assignable to type 'StyleProp<ImageStyle>'.
Type 'ViewStyle' is not assignable to type 'ImageStyle'.
Overload 2 of 2, '(props: ImageProps, context?: any): Image', gave the following error.
Type 'ViewStyle | TextStyle | ImageStyle' is not assignable to type 'StyleProp<ImageStyle>'.
Type 'ViewStyle' is not assignable to type 'StyleProp<ImageStyle>'.
Type 'ViewStyle' is not assignable to type 'ImageStyle'.
If I remove the usage of the NamedStyles
typing helper, and keep the S
type as it, it works well and I got the correct type from TS.
I can provide a PR if it can help and if this solution is okay for you :)
Is a PR too late to ask for?
No :) https://github.com/wvteijlingen/react-native-themed-styles/pull/6
Also it allow to use another types
import { StatusBarStyle } from "react-native";
export const lightTheme = {
barStyle: "dark-content" as StatusBarStyle,
backgroundColor: "#ffffff",
textColor: "#000000",
};