Shopify / restyle

A type-enforced system for building UI components in React Native with TypeScript.

Home Page:https://shopify.github.io/restyle/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect type definition with useRestyle

ludwig-pro opened this issue · comments

Hello! I have an incorrect type definition with useRestyle =>

here is an example https://snack.expo.dev/@ludwig-pro/expo-typescript-restyle

there are two components :

RestyleButton.tsx (a copy / paste of the README )
RestyleBox.tsx - a custom box to handle opacity props

image

a regression introduced by https://github.com/Shopify/restyle/pull/138/files

Any solution for this?

this issue has been so long, any progress here?

Any progress on this issue? Following the custom component example I am getting:

No overload matches this call.
  Overload 1 of 2, '(props: ViewProps | Readonly<ViewProps>): View', gave the following error.
    Type '{ children: Element; margin?: ResponsiveValue<"px" | "0" | "0.5" | "1" | "1.5" | "2" | "2.5" | "3" | "3.5" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "12" | "16" | "20" | "24" | "32" | "40" | ... 21 more ... | "full", { ...; }> | undefined; ... 45 more ...; style: ((...args: any[]) => (false | ... 6 more ... | und...' is not assignable to type 'Readonly<ViewProps>'.
      Types of property 'style' are incompatible.
        Type '((...args: any[]) => (false | ViewStyle | ImageStyle | RegisteredStyle<ViewStyle> | RecursiveArray<ViewStyle | Falsy | RegisteredStyle<...>> | ((...args: any[]) => StyleProp<...>) | null | undefined)[]) | (false | ... 6 more ... | undefined)[]' is not assignable to type 'StyleProp<ViewStyle>'.
          Type '(...args: any[]) => (false | ViewStyle | ImageStyle | RegisteredStyle<ViewStyle> | RecursiveArray<ViewStyle | Falsy | RegisteredStyle<...>> | ((...args: any[]) => StyleProp<...>) | null | undefined)[]' is not assignable to type 'StyleProp<ViewStyle>'.
  Overload 2 of 2, '(props: ViewProps, context: any): View', gave the following error.
    Type '{ children: Element; margin?: ResponsiveValue<"px" | "0" | "0.5" | "1" | "1.5" | "2" | "2.5" | "3" | "3.5" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "12" | "16" | "20" | "24" | "32" | "40" | ... 21 more ... | "full", { ...; }> | undefined; ... 45 more ...; style: ((...args: any[]) => (false | ... 6 more ... | und...' is not assignable to type 'Readonly<ViewProps>'.
      Types of property 'style' are incompatible.
        Type '((...args: any[]) => (false | ViewStyle | ImageStyle | RegisteredStyle<ViewStyle> | RecursiveArray<ViewStyle | Falsy | RegisteredStyle<...>> | ((...args: any[]) => StyleProp<...>) | null | undefined)[]) | (false | ... 6 more ... | undefined)[]' is not assignable to type 'StyleProp<ViewStyle>'.ts(2769)

it looks like 2.4.0 has solved this problem. I tried the latest version in my project and it works fine.

Thanks @chj-damon 🙏 Let us know if the issue still persists.