Skip to content

[Types] Remove onUpdate from discrete gestures - #3811

Merged
j-piasecki merged 1 commit into
nextfrom
@jpiasecki/remove-onupdate-discrete-gestures
Nov 12, 2025
Merged

j-piasecki merged 1 commit into
nextfrom
@jpiasecki/remove-onupdate-discrete-gestures

Conversation

@j-piasecki

Copy link
Copy Markdown
Member

Description

Discrete gestures shouldn't be sending update events, so the onUpdate method shouldn't be accepted by the type definitions.

It also moves the type definitions for events and gestures above the hook definition. I'm pretty sure it was also correct before, but I think it's cleaner when things are declared before they are used. LMK what you think.

Test plan

  const tap = useTap({
    onUpdate: () => {
      'worklet';
    },
  });

  const fling = useFling({
    onUpdate: () => {
      'worklet';
    },
  });

  const longpress = useLongPress({
    onUpdate: () => {
      'worklet';
    },
  });

  const native = useNative({
    onUpdate: () => {
      'worklet';
    },
  });

FlingGestureProperties
>;

export function useFling(config: FlingGestureConfig): FlingGesture {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is specifying return type necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Without it, the type is inferred from useGesture, which doesn't know what kind of gesture it creates, so all are typed the same as continuous gestures. Another benefit is that gestures are now using named types.

@j-piasecki
j-piasecki merged commit 7b2ecaa into next Nov 12, 2025
2 checks passed
@j-piasecki
j-piasecki deleted the @jpiasecki/remove-onupdate-discrete-gestures branch November 12, 2025 15:26
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