Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the typing of HitSlop in the v3 gesture config so that SharedValue can be used with HitSlop (e.g. useSharedValue(10)) without type errors and tightens the typing around config value unwrapping.
Changes:
- Refactors
SharedValueOrT/WithSharedValueto use distributive conditional types and aPparameter to selectively prevent union splitting, then removesHitSlopfrom the non-splittable set, allowingSharedValue<number>etc. to be assignable whereHitSlopis expected. - Narrows
maybeUnpackValue’s input type usingSharedValueOrT<T, boolean> | undefinedand updates call sites to specify the expected value type (e.g.<number>,<boolean>), improving type inference and safety when unwrapping config values. - Exposes the
ActiveCursortype from the package root index for consumers using the new v3 gesture config APIs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/react-native-gesture-handler/src/v3/types/ReanimatedTypes.ts |
Introduces the new SharedValueOrT<T, P> implementation and wires it into WithSharedValue/WithSharedValueRecursive to support union splitting with an escape hatch via P. |
packages/react-native-gesture-handler/src/v3/types/ConfigTypes.ts |
Updates CommonGestureConfig’s WithSharedValue parameter to only treat ActiveCursor and MouseButton as non-splittable, so HitSlop now benefits from the new union-splitting behavior. |
packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts |
Refines maybeUnpackValue’s signature to use SharedValueOrT<T, boolean> and return T, ensuring correct handling of boolean config flags and shared values. |
packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/usePanGesture.ts |
Adds explicit type parameters to maybeUnpackValue calls for pan offsets, ensuring numbers are correctly inferred when validating and transforming offset props. |
packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts |
Adjusts use of maybeUnpackValue for enabled in test utilities to specify <boolean>, aligning with the new generic signature. |
packages/react-native-gesture-handler/src/index.ts |
Re-exports the ActiveCursor type from gestureHandlerCommon, making it available to library consumers at the package root. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
j-piasecki
approved these changes
Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Though we allowed
HitSlopto beSharedValuein gesture config, we excluded it from being split. Therefore if someone did something like:this wouldn't work as
SharedValue<number>couldn't be assigned toSharedValue<HitSlop>.This PR changes behavior of
SharedValueOrT<T>type, so that it uses Distributive Conditional Types to split union into separate types and then applySharedValue.Test plan
yarn ts-checkandyarn lint-jsTested on the following code: