Repository navigation
Conversation
`userEvent.setup()` returns a `UserEventInstance`, but the package exports only `UserEventConfig`. A helper that returns or receives the instance had to import the type from `dist/user-event/setup` or write `ReturnType<typeof userEvent.setup>`. `RenderResult` and `RenderHookResult` are exported for the same reason. `setup()` now declares `UserEventInstance` as its return type, so the exported type cannot drift from what `setup()` returns. `src/user-event/index.ts` re-exports both interfaces with `export type`. A plain `export` made Babel emit a getter for each interface in `dist/user-event/index.js` that returns `undefined`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
psjostrom
marked this pull request as ready for review
November 26, 2026 15:39
This branch has not been deployed
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.
Summary
UserEventInstancetype from the package root, next toUserEventConfig.setup()declaresUserEventInstanceas its return type, and thesetup()docs show it.src/user-event/index.tsre-exports both interfaces withexport type. A plainexportmade Babel emit a getter for each interface indist/user-event/index.js, and the getter returnsundefined.We have a test helper that returns
{ screen, user }. To name the type ofuser, it imports from@testing-library/react-native/dist/user-event/setup, and that path broke when v14 movedbuild/todist/. The other option isReturnType<typeof userEvent.setup>. #1091 exportedRenderResultandRenderHookResultfor the same reason.Test plan
yarn validatepasses, with 955 tests.import type { RenderResult, UserEventInstance } from '@testing-library/react-native'fails with TS2305. With this branch's build innode_modules, the same import typechecks, and the app's tests that use the helper pass.dist/user-event/index.jsfromyarn buildhas noUserEventConfigorUserEventInstanceexport.