-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add types for ElementRef
support
#237
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
P extends Omit<Props, 'variant' | 'variants'> = Omit< | ||
Props, | ||
'variant' | 'variants' | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is 🔥🔥🔥 I never knew how to get inferred refs to get to work. I'd love to get this to work for |
One thing – I'm getting this error when I run src/css/create-themed-component.tsx(48,52): error TS2345: Argument of type 'PropsWithChildren<StyledProps<ThemeKey> & Props>' is not assignable to parameter of type 'ExtraProps'.
'ExtraProps' could be instantiated with an arbitrary type which could be unrelated to 'PropsWithChildren<StyledProps<ThemeKey> & Props>'. |
I added a commit to ignore it – I think it's fine since it's just an implementation detail. |
Let me know if it's good to go, and I'll merge + release. |
i'll take a quick look at that issue, i think i know the cause... |
@nandorojo all should be good to go now :) |
Published in |
@nandorojo hmmm, i've pulled the latest version and for some reason the following code is fine in this project but errors in mine. does this work for you? interface CircleProps {
size?: number
color?: 'red' | 'green'
}
const Circle = styled(View)<CircleProps>((props) => ({
width: props.size || 56,
height: props.size || 56,
backgroundColor: props.color ?? 'transparent',
borderRadius: 9999,
justifyContent: 'center',
alignItems: 'center',
overflow: 'hidden',
}))
export const Foo = () => {
return (
<Circle
size={20}
sx={{
backgroundColor: 'crimson',
position: 'absolute',
right: -6,
bottom: 2,
}}
/>
)
} |
Oh, it's because the first generic of |
const Circle = styled(View)((props: CircleProps) => ({ This fixes it, but it still keeps a breaking change. |
I think this should fix it: export function styled<
Props,
C extends ComponentType<any>,
ThemeKey extends keyof DripsyFinalTheme = keyof DripsyFinalTheme
>(
Component: C,
{
themeKey,
defaultVariant,
}: Pick<ThemedOptions<any, ThemeKey>, 'themeKey' | 'defaultVariant'> = {}
) {
return function dripsyFactory<Extra>(
defaultStyle?: ThemedOptions<Extra & Props, ThemeKey>['defaultStyle']
) {
return createThemedComponent<C, Extra & Props, ThemeKey>(Component, {
defaultVariant,
themeKey,
defaultStyle,
})
}
} This way, we can still explicitly pass a props generic to |
Hm, that actually did not fix it for me. I'll have to keep looking. |
Closes #225