Skip to content

Make stylusData property of the GestureUpdateEvent optional #3270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

kkafar
Copy link
Member

@kkafar kkafar commented Dec 9, 2024

Description

Idk what's your policy on types & whether the type stylusData: StylusData | undefined type is intended in this form or not,
but currently when creating event of type GestureUpdateEvent<PanGestureHandlerEventPayload> user is forced to specify
stylusData even if there is none - in such case stylusData: undefined must be passed; the prop can not be just simply omitted.

image

I'm humbly suggesting that you consider relaxing these types a bit to stylusData?: StylusData | undefined, so that it
does not have to be always specified.

Context: this is just quality of life improvement IMO, not crucial. I've stubmled upon this when I've bumped version of gesture-handler in react-native-screens (link)

  • current types forced me to add this field, and I've thought this is not pleasant.

Test plan

N/A, every thing should work as before

@kkafar
Copy link
Member Author

kkafar commented Dec 9, 2024

Note: it is possible that the type should be adjusted in few other places to account for this change. I'll update the code once you confirm that you would agree for such change; otherwise I don't want to spend time on it 😄

@@ -126,7 +126,7 @@ export type PanGestureHandlerEventPayload = {
/**
* Object containing additional stylus data.
*/
stylusData: StylusData | undefined;
stylusData?: StylusData | undefined;
Copy link
Member

@latekvo latekvo Dec 9, 2024

Choose a reason for hiding this comment

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

Sounds good, I think we can remove | undefined now, since it's redundant.

Suggested change
stylusData?: StylusData | undefined;
stylusData?: StylusData;

@latekvo latekvo changed the title feat: do not force user to pass stylus options Make stylusData property of the GestureUpdateEvent optional Dec 9, 2024
@kkafar kkafar merged commit 36a99f3 into main Dec 9, 2024
1 check passed
@kkafar kkafar deleted the @kkafar/type-suggestion branch December 9, 2024 15:28
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