th3rdwave / react-native-safe-area-context

A flexible way to handle safe area insets in JS. Also works on Android and Web!
MIT License
2.16k stars 200 forks source link

[TS]: Error for withSafeAreaInsets due to @types/react forwardRef update #526

Closed akuul closed 1 month ago

akuul commented 2 months ago

Hello,

just bringing awareness here that due to @types/react^18.3.5 and changes made to the forwardRef function, withSafeAreaInsets is throwing a Typescript error.

Argument of type '(props: T, ref: React.Ref<unknown>) => React.JSX.Element' is not assignable to parameter of type 'ForwardRefRenderFunction<unknown, PropsWithoutRef<T>>'.
  Types of parameters 'props' and 'props' are incompatible.
    Type 'PropsWithoutRef<T>' is not assignable to type 'T'.
      'T' could be instantiated with an arbitrary type which could be unrelated to 'PropsWithoutRef<T>'.

I have patched T to use PropsWithoutRef<T>that resolves the issue, but this is temporary solution as it is not compatible with @types/react^18.3.4

abrah4mr commented 1 month ago

Same error here, is there any solution to this @janicduplessis?

jacobp100 commented 1 month ago

If you can submit a PR that fixes the issue without breaking older versions, we’ll merge. Otherwise, you could also open an issue on the react types package as to why it broke other packages

abrah4mr commented 1 month ago

So, this is a issue related with react types? @jacobp100

abrah4mr commented 1 month ago

Also, is happening on older versions too, I have currently the 4.7.4 in my project.