nandorojo / solito

🧍‍♂️ React Native + Next.js, unified.
https://solito.dev
MIT License
3.54k stars 181 forks source link

V3 typescript compatibility with Nativewind #348

Closed sgrund14 closed 1 year ago

sgrund14 commented 1 year ago

hello,

noticed that the new V3 of SolitoImage is throwing a typescript error when wrapped with styled from Nativewind

Screenshot 2023-03-07 at 6 48 42 PM

Seems to still be working otherwise...

nandorojo commented 1 year ago

This is likely a bug with the nativewind types. I recommend opening an issue there.

sgrund14 commented 1 year ago

got it, although noticed that it wasn't happening on Solito V2 🤔

sgrund14 commented 1 year ago

oh, I see. now nativewind wants me to be explicit about the props I pass in for some reason

import { styled } from 'nativewind';
import { SolitoImageProps } from 'solito/build/image/image.types';
import { SolitoImage } from 'solito/image';
export const StyledImage = styled<SolitoImageProps>(SolitoImage);

is required to satisfy typescript in V3. seems like a workaround...

fwiw, the props of the SolitoImage did change from V2 -> V3

V2

function SolitoImage(props: Omit<SolitoImageProps, 'resizeMode' | 'style'> & Pick<ComponentProps<typeof FastImage>, 'style' | 'resizeMode'>): JSX.Element

V3

const SolitoImage: ForwardRefExoticComponent<SolitoImageProps & RefAttributes<Image>>