In order to have a common style that applied to both the web and the native versions you need to make sure that it passes the type checks for both types. What you have now requires that buttonStyle
is assignable to React.CSSProperties
or ViewStyle
. You need to require that it is assignable to both in order to use that style on a View
and a button
. Just switch your |
(which is a union) to &
(which is an intersection).
export interface IButtonStyle extends INavigationStyle {
buttonStyle: React.CSSProperties & ViewStyle;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…