birdwingo / react-native-swipe-modal

🚀 Swipe modal is a customizable and animated modal component that can be used in React Native applications. It provides a smooth swipe-to-close functionality along with various configuration options to suit different use cases.
https://birdwingo.com
MIT License
42 stars 1 forks source link

Typescript build error in components/SwipeModal/scroll.tsx #25

Open stuart-responsible opened 3 days ago

stuart-responsible commented 3 days ago

We are seeing a typescript error when building with this package.

Here is the diff that solved my problem:

diff --git a/node_modules/@birdwingo/react-native-swipe-modal/src/components/SwipeModal/scroll.tsx b/node_modules/@birdwingo/react-native-swipe-modal/src/components/SwipeModal/scroll.tsx
index 300011f..b3e77d9 100644
--- a/node_modules/@birdwingo/react-native-swipe-modal/src/components/SwipeModal/scroll.tsx
+++ b/node_modules/@birdwingo/react-native-swipe-modal/src/components/SwipeModal/scroll.tsx
@@ -20,6 +20,7 @@ const ModalScrollView: FC<ModalScrollContainerProps> = ( {
   return (
     <AnimatedScrollView
       {...props}
+      hitSlop={undefined}
       testID="modalScrollView"
       ref={scrollRef}
       showsVerticalScrollIndicator={false}
LukasFridmansky commented 3 days ago

Hello, I would say that the issue is probably with react-native-gesture-detector. We didn't experience this problem. Do you you use the latest version? If the problem persists, you can use scrollContainerProps={{hitSlop: undefined}} and it should work.

stuart-responsible commented 3 days ago

@LukasFridmansky Thanks for the quick response. We are using the latest version of this package. Unfortunately passing the hitSlop value in the scroll container props object has not worked.

I've tested this on a clean react native expo app and still seem to be getting the error when running tsc. The component itself works fine the issue is only present during type-checking.

❯ npx tsc
node_modules/@birdwingo/react-native-swipe-modal/src/components/SwipeModal/scroll.tsx:21:6 - error TS2322: Type '{ children: ReactNode; testID: string; ref: RefObject<ScrollView>; showsVe
node_modules/@birdwingo/react-native-swipe-modal/src/components/SwipeModal/scroll.tsx:21:6 - error TS2322: Type '{ children: ReactNode; testID: string; ref: RefObject<ScrollView>; showsVerticalScrollIndicator: false; onScrollBeginDrag: () => void; onScroll: (e: NativeSyntheticEvent<...>) => void; ... 137 more ...; persistentScrollbar?: boolean | undefined; }' is not assig
node_modules/@birdwingo/react-native-swipe-modal/src/components/SwipeModal/scroll.tsx:21:6 - error TS2322: Type '{ children: ReactNode; testID: string; ref: RefObject<ScrollView>; showsVerticalScrollIndicator: false; onScrollBeginDrag: () => void; onScroll: (e: NativeSyntheticEvent<...>) => void; ... 137 more ...; persistentScrollbar?: boolean | undefined; }' is not assignable to type 'RestProps<ScrollViewProps & NativeViewGestureHandlerProps & RefAttributes<ScrollView>>'.
  Types of property 'hitSlop' are incompatible.
    Type 'number | Insets | null | undefined' is not assignable to type '((number | Insets | null) & HitSlop) | SharedValue<((number | Insets | null) & HitSlop) | undefined> | undefined'.
      Type 'null' is not assignable to type '((number | Insets | null) & HitSlop) | SharedValue<((number | Insets | null) & HitSlop) | undefined> | undefined'.

21     <AnimatedScrollView
        ~~~~~~~~~~~~~~~~~~

Found 1 error in node_modules/@birdwingo/react-native-swipe-modal/src/components/SwipeModal/scroll.tsx:21