fakeheal / react-native-pan-pinch-view

🔍 A view component for React Native with pinch to zoom and drag to pan functionality.
MIT License
76 stars 14 forks source link

Error preventing new pull requests: Cannot find module 'react-native-gesture-handler' or its corresponding type declarations. #11

Open jordan-vdi opened 5 months ago

jordan-vdi commented 5 months ago

I am trying to get this project running locally so I can attempt some pull requests, but I am running into a consistent typescript error after installing.

After installing and running yarn typecheck I receive these errors.

src/index.tsx:7:8 - error TS2307: Cannot find module 'react-native-gesture-handler' or its corresponding type declarations.

7 } from 'react-native-gesture-handler';
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/index.tsx:14:8 - error TS2307: Cannot find module 'react-native-gesture-handler' or its corresponding type declarations.

14 } from 'react-native-gesture-handler';
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/index.tsx:21:8 - error TS2307: Cannot find module 'react-native-reanimated' or its corresponding type declarations.

21 } from 'react-native-reanimated';
          ~~~~~~~~~~~~~~~~~~~~~~~~~

src/math.ts:1:42 - error TS2307: Cannot find module 'react-native-reanimated' or its corresponding type declarations.

1 import Animated, { useSharedValue } from 'react-native-reanimated';
                                           ~~~~~~~~~~~~~~~~~~~~~~~~~

Found 4 errors in 2 files.

Errors  Files
     3  src/index.tsx:7
     1  src/math.ts:1

I'll continue to investigate, I figured it was worth mentioning here for visibility.

jordan-vdi commented 5 months ago

I found this comment while digging through some issues on the yarn repo.

https://github.com/yarnpkg/yarn/issues/5347#issuecomment-463038189

It seems this is a common practice. The recommendation would be to switch the two dependencies from peer dependencies to actual dependencies. This would ensure that these dependencies are installed when running yarn.

I made the in my local project and the errors went away.

I'm curious if you were doing anything else to deal with these errors.

fakeheal commented 5 months ago

I've added them as peerDependencies, because both react-native-reanimated and react-native-gesture-handler require additional setup for them to work properly on all platforms.

In the README of this repository I've mentioned that before installing react-native-pan-pinch-view you need to have those two packages installed & setup. I've also specified versions of said packages, because they tend to introduce breaking changes freqently.

jordan-vdi commented 5 months ago

@fakeheal Yup, and that works in the project that I am using this in. I see that the peerDependencies should stay.

The issue that I am running into is when I tried to add the feature mentioned in #10. In a development context the two dependencies need to be present in order to pass the yarn typecheck which is a contribution requirement.

jordan-vdi commented 5 months ago

It looks like you accounted for this by using install-peers, but that didn't work for me. It might be related to this. https://github.com/alexindigo/install-peers/issues/8

fakeheal commented 4 months ago

Oh, I see, sorry I kind of misunderstood your first comment.

I will have to delve deeper into the install-peers and how to handle peerDependencies in npm packages with demos.