fix(app): type composed sheet gesture relations

This commit is contained in:
Mohamed Boudra
2026-11-15 12:35:05 +01:00
parent 6adf92f089
commit f69dc31086
2 changed files with 47 additions and 15 deletions
@@ -335,15 +335,21 @@ describe("IsolatedBottomSheetModal content drag", () => {
);
});
// Exercise the library boundary as well as the modal props: nested refs used to be silently dropped.
import BottomSheetDraggableView from "@gorhom/bottom-sheet/src/components/bottomSheetDraggableView/BottomSheetDraggableView";
import { BottomSheetInternalContext } from "@gorhom/bottom-sheet/src/contexts/internal";
import {
BottomSheetDraggableContext,
BottomSheetGestureHandlersContext,
} from "@gorhom/bottom-sheet/src/contexts/gesture";
import { Gesture } from "react-native-gesture-handler";
import { extractGestureRelations } from "react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils";
// Load the real vendored implementations at runtime without typechecking Gorhom's entire source
// tree (its hooks barrel reaches upstream files that don't compile under the app's TS settings).
const gorhomSource = "@gorhom/bottom-sheet/src";
const { default: BottomSheetDraggableView } = await import(
`${gorhomSource}/components/bottomSheetDraggableView/BottomSheetDraggableView`
);
const { BottomSheetInternalContext } = await import(`${gorhomSource}/contexts/internal`);
const { BottomSheetDraggableContext, BottomSheetGestureHandlersContext } = await import(
`${gorhomSource}/contexts/gesture`
);
const rnghSource = "react-native-gesture-handler/src";
const { extractGestureRelations } = await import(
`${rnghSource}/handlers/gestures/GestureDetector/utils`
);
import { Gesture, type GestureType } from "react-native-gesture-handler";
const noGestureWork = () => {};
const gestureHandlerContext = {
@@ -365,7 +371,7 @@ function dragInternalContext(relations: SheetContentDragGesture | SheetContentDr
enableContentPanningGesture: true,
waitFor: relations,
simultaneousHandlers: relations,
} as React.ContextType<typeof BottomSheetInternalContext>;
};
}
describe("bottom sheet native drag relations", () => {
@@ -381,7 +387,7 @@ describe("bottom sheet native drag relations", () => {
let resolved: ReturnType<typeof extractGestureRelations> | undefined;
const internal = dragInternalContext(relations);
function Probe() {
const pan = useContext(BottomSheetDraggableContext);
const pan = useContext(BottomSheetDraggableContext) as GestureType | null;
if (pan) resolved = extractGestureRelations(pan);
return null;
}
+30 -4
View File
@@ -196,6 +196,19 @@ index 8259637..eb057fe 100644
export { useScrollEventsHandlersDefault } from './hooks/useScrollEventsHandlersDefault';
export { useGestureEventsHandlersDefault } from './hooks/useGestureEventsHandlersDefault';
export { useBottomSheetGestureHandlers } from './hooks/useBottomSheetGestureHandlers';
diff --git a/node_modules/@gorhom/bottom-sheet/lib/typescript/components/bottomSheet/types.d.ts b/node_modules/@gorhom/bottom-sheet/lib/typescript/components/bottomSheet/types.d.ts
index 6b23056..8d92aae 100644
--- a/node_modules/@gorhom/bottom-sheet/lib/typescript/components/bottomSheet/types.d.ts
+++ b/node_modules/@gorhom/bottom-sheet/lib/typescript/components/bottomSheet/types.d.ts
@@ -353,6 +353,6 @@ export type BottomSheetGestureProps = {
simultaneousHandlers: Parameters<
PanGesture['simultaneousWithExternalGesture']
- >[0];
- waitFor: Parameters<PanGesture['requireExternalGestureToFail']>[0];
+ >[0] | Parameters<PanGesture['simultaneousWithExternalGesture']>;
+ waitFor: Parameters<PanGesture['requireExternalGestureToFail']>[0] | Parameters<PanGesture['requireExternalGestureToFail']>;
};
diff --git a/node_modules/@gorhom/bottom-sheet/lib/typescript/index.d.ts b/node_modules/@gorhom/bottom-sheet/lib/typescript/index.d.ts
index ffc6caa..550f1b3 100644
--- a/node_modules/@gorhom/bottom-sheet/lib/typescript/index.d.ts
@@ -209,8 +222,21 @@ index ffc6caa..550f1b3 100644
export { useScrollEventsHandlersDefault } from './hooks/useScrollEventsHandlersDefault';
export { useGestureEventsHandlersDefault } from './hooks/useGestureEventsHandlersDefault';
export { useBottomSheetGestureHandlers } from './hooks/useBottomSheetGestureHandlers';
diff --git a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/types.d.ts b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/types.d.ts
index 6b23056..8d92aae 100644
--- a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/types.d.ts
+++ b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/types.d.ts
@@ -353,6 +353,6 @@ export type BottomSheetGestureProps = {
simultaneousHandlers: Parameters<
PanGesture['simultaneousWithExternalGesture']
- >[0];
- waitFor: Parameters<PanGesture['requireExternalGestureToFail']>[0];
+ >[0] | Parameters<PanGesture['simultaneousWithExternalGesture']>;
+ waitFor: Parameters<PanGesture['requireExternalGestureToFail']>[0] | Parameters<PanGesture['requireExternalGestureToFail']>;
};
diff --git a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetDraggableView/BottomSheetDraggableView.tsx b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetDraggableView/BottomSheetDraggableView.tsx
index 923e430..5f68852 100644
index 923e430..eeef8cf 100644
--- a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetDraggableView/BottomSheetDraggableView.tsx
+++ b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetDraggableView/BottomSheetDraggableView.tsx
@@ -65,12 +65,12 @@ const BottomSheetDraggableViewComponent = ({
@@ -224,12 +250,12 @@ index 923e430..5f68852 100644
if (simultaneousHandlers) {
gesture = gesture.simultaneousWithExternalGesture(
- simultaneousHandlers as never
+ ...simultaneousHandlers
+ ...(simultaneousHandlers as Parameters<typeof gesture.simultaneousWithExternalGesture>)
);
}
diff --git a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetHandle/BottomSheetHandleContainer.tsx b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetHandle/BottomSheetHandleContainer.tsx
index 0223843..c72196f 100644
index 0223843..4ca56e5 100644
--- a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetHandle/BottomSheetHandleContainer.tsx
+++ b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetHandle/BottomSheetHandleContainer.tsx
@@ -67,12 +67,12 @@ function BottomSheetHandleContainerComponent({
@@ -243,7 +269,7 @@ index 0223843..c72196f 100644
if (simultaneousHandlers) {
gesture = gesture.simultaneousWithExternalGesture(
- simultaneousHandlers as never
+ ...simultaneousHandlers
+ ...(simultaneousHandlers as Parameters<typeof gesture.simultaneousWithExternalGesture>)
);
}