Skip to content

Update Swipeable types#4175

Draft
m-bert wants to merge 10 commits into
mainfrom
@mbert/update-types
Draft

Update Swipeable types#4175
m-bert wants to merge 10 commits into
mainfrom
@mbert/update-types

Conversation

@m-bert
Copy link
Copy Markdown
Collaborator

@m-bert m-bert commented May 13, 2026

Description

Some of the props passed to Swipeable can be SharedValue. However, we do not allow that in types, so TypeScript throws errors.

Test plan

Static checks

Copilot AI review requested due to automatic review settings May 13, 2026 14:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the public TypeScript API for ReanimatedSwipeable to reflect that certain numeric configuration props may be provided as Reanimated SharedValue<number>, aligning the typings/docs with intended usage.

Changes:

  • Expand SwipeableProps.dragOffsetFromLeft and SwipeableProps.dragOffsetFromRight to accept SharedValue<number> in addition to number.
  • Update the Reanimated Swipeable docs to reflect the updated prop types.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts Widens dragOffsetFromLeft/dragOffsetFromRight prop types to include SharedValue<number>.
packages/docs-gesture-handler/docs/components/reanimated_swipeable.mdx Updates the documented TypeScript signatures for the same props.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx:489

  • activeOffsetX requires the first tuple element to be <= 0 and the second to be >= 0 (validated by usePanGesture in DEV). Switching to [dragOffsetFromRight, dragOffsetFromLeft] changes the sign contract for dragOffsetFromRight compared to the documented/default behavior ("Defaults to 10"), and will break existing callers passing a positive number. Prefer preserving the existing API (positive distance) and handling the negation internally in a way that supports SharedValue, or update the default value + docs to explicitly require a non-positive dragOffsetFromRight.
  const panGesture = usePanGesture({
    enabled: enabled !== false,
    enableTrackpadTwoFingerGesture: enableTrackpadTwoFingerGesture,
    activeOffsetX: [dragOffsetFromRight, dragOffsetFromLeft],
    simultaneousWith,
    requireToFail,

Comment thread packages/docs-gesture-handler/docs/components/reanimated_swipeable.mdx Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread packages/docs-gesture-handler/docs/guides/upgrading-to-3.mdx Outdated
Comment on lines +68 to +78
useEffect(() => {
if (__DEV__) {
const value = maybeUnpackValue<number>(dragOffsetFromRight);

if (value > 0) {
throw new Error(
tagMessage('dragOffsetFromRight should be non-positive.')
);
}
}
}, [dragOffsetFromRight]);
Comment thread skills/gesture-handler-3-migration/SKILL.md
m-bert and others added 2 commits May 14, 2026 10:34
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants