Skip to content

Remove the @ts-ignore TODO from the event pipeline in jestUtils - #4460

Merged
m-bert merged 1 commit into
mainfrom
@mbert/jest-utils-remove-ts-ignore
Aug 21, 2026
Merged

Remove the @ts-ignore TODO from the event pipeline in jestUtils#4460
m-bert merged 1 commit into
mainfrom
@mbert/jest-utils-remove-ts-ignore

Conversation

@m-bert

@m-bert m-bert commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Description

fireGestureHandler reused a single let _ variable for every stage of the event pipeline, so its type was fixed by the first assignment as EventWithoutStates[]. The final _.map(wrapWithNativeEvent) step didn't type-check against it, which was suppressed with // @ts-ignore TODO followed by an as unknown as double cast.

This PR collapses the last two steps into a single map with one honest cast (by that point the pipeline has filled in state and oldState), the same pattern the file already uses in the other wrapWithNativeEvent call sites. Also replaces events.shift()! with destructuring, which removes a no-non-null-assertion lint warning.

No behavior change.

Test plan

  • yarn ts-check passes without the suppression
  • yarn test — 18 suites, 156 tests pass, including calls to fireGestureHandler with an empty event list (the only edge where shift() could differ)

Copilot AI lite review requested due to automatic review settings August 20, 2026 13:42
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 07361e0c-dc9d-4bf9-8158-d91fd77e40f1

📥 Commits

Reviewing files that changed from the base of the PR and between 0785d6d and 59527d0.

📒 Files selected for processing (1)
  • packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved gesture handler test utilities to process mapped gesture events more reliably.
    • Prevented unintended changes to event sequences during gesture simulation.

Walkthrough

Changes

Gesture handler event wrapping

Layer / File(s) Summary
Non-mutating event wrapping
packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts
fireGestureHandler maps events to wrapped native-event objects, separates the first event, and iterates over the remaining events without mutating the array.

Merge Risk: ⚪ Minimal · up to 59527

This localized cleanup removes a TypeScript suppression and lint issue without changing behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing the @ts-ignore TODO from the jestUtils event pipeline.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 removes a TypeScript suppression (// @ts-ignore TODO) and the associated unsafe double-cast in fireGestureHandler within the Jest utilities, keeping the event pipeline type-safe without altering runtime behavior.

Changes:

  • Replaces the suppressed _.map(wrapWithNativeEvent) + as unknown as cast with a single map that performs one explicit cast per event before wrapping.
  • Replaces events.shift()! with array destructuring to avoid a non-null assertion (and the related lint warning).
  • Updates the iteration to use restEvents after extracting the first event.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@m-bert
m-bert merged commit 592d951 into main Aug 21, 2026
6 checks passed
@m-bert
m-bert deleted the @mbert/jest-utils-remove-ts-ignore branch August 21, 2026 06:30
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.

3 participants