Skip to content

Comments

feat: add support for globalThis in event handling functions#1373

Open
THernandez03 wants to merge 1 commit intotesting-library:mainfrom
THernandez03:pr/add-globalThis-for-events
Open

feat: add support for globalThis in event handling functions#1373
THernandez03 wants to merge 1 commit intotesting-library:mainfrom
THernandez03:pr/add-globalThis-for-events

Conversation

@THernandez03
Copy link

What: Add GlobalThis to the event type definitions for fireEvent and createEvent.

Why: globalThis is a valid event target (it references window in browser environments), but the current type definitions don't accept it. This causes false type errors when firing or creating events on globalThis.

How:

  • Added GlobalThis to the union types in FireFunction, FireObject, CreateFunction, and CreateObject in types/events.d.ts.
  • Added type tests in types/__tests__/type-tests.ts to validate globalThis is accepted by fireEvent and createEvent.

Checklist:

  • Documentation added to the
    docs site N/A
  • Tests
  • TypeScript definitions updated
  • Ready to be merged

Copilot AI review requested due to automatic review settings February 12, 2026 04:42
@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 12, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 8132254:

Sandbox Source
react-testing-library-examples Configuration

Copy link

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 pull request attempts to add support for globalThis as a valid event target in the TypeScript type definitions for fireEvent and createEvent functions. The goal is to allow developers to use globalThis (which references window in browser environments) without encountering false type errors.

Changes:

  • Modified type definitions in types/events.d.ts to include GlobalThis in union types for event handling functions
  • Added TypeScript type tests in types/__tests__/type-tests.ts to validate globalThis usage

Reviewed changes

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

File Description
types/events.d.ts Added GlobalThis to union types in FireFunction, FireObject, CreateFunction, and CreateObject interfaces
types/tests/type-tests.ts Added type tests for fireEvent.click(globalThis), createEvent('customEvent', globalThis), and fireEvent(globalThis, event)

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

@THernandez03 THernandez03 force-pushed the pr/add-globalThis-for-events branch from 7152fdf to d9f23df Compare February 12, 2026 04:55
@THernandez03 THernandez03 force-pushed the pr/add-globalThis-for-events branch from d9f23df to 8132254 Compare February 12, 2026 05:02
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.

1 participant