You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeTextBaseProps={color: string};constTextBase=styled.Text<TextBaseProps>` color: ${props=>props.theme.typography.color}; font-family: 'crossfit-bold';`;// 1. This way only types `any` (uppercase is any...)exportconstStyledHeaderAny=styled(TextBase)<{uppercase: boolean;big: boolean;}>` text-transform: ${({uppercase})=>(uppercase ? 'uppercase' : 'none')}; font-size: ${({big})=>(big ? 52 : 12)}px; color: ${({color})=>color??props.theme.typography.color};`;// 2. This way I got proper types (uppercase is boolean...)exportconstStyledHeaderProperTypes=styled((props: TextBaseProps)=>(<TextBase{...props}/>))<{uppercase: boolean;big: boolean;children: React.ReactNode}>` text-transform: ${({uppercase})=>(uppercase ? 'uppercase' : 'none')}; font-size: ${({big})=>(big ? 52 : 12)}px; color: ${({color})=>color??props.theme.typography.color};`;
I don't know why this is happening, why I got type any using the styled() form but proper types with styled(() => ) style? Is n. 2 style the only way?
I'm using SC 5.3.5 with last @types/styled-components @types/styled-components-react-native
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm using Styled Component with TS. I got this
I don't know why this is happening, why I got type any using the styled() form but proper types with styled(() => ) style? Is n. 2 style the only way?
I'm using SC 5.3.5 with last @types/styled-components @types/styled-components-react-native
Beta Was this translation helpful? Give feedback.
All reactions