fix: Move jest/mock into package build (fix TS under RN 0.87) - #745
Merged
Conversation
huntie
commented
Jul 30, 2026
| @@ -0,0 +1 @@ | |||
| module.exports = require('../lib/commonjs/jest/mock'); | |||
Contributor
Author
There was a problem hiding this comment.
Note: After #740, we could introduce an "exports" entry to replace these shims (non-breaking).
Collaborator
There was a problem hiding this comment.
Do u know what is minimum version of rn / metro that supports exports?
This was referenced Jul 30, 2026
janicduplessis
approved these changes
Aug 3, 2026
janicduplessis
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @huntie !
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
Minimal fix for
react-native-safe-area-contextcompatibility in React Native 0.87 projects. See react-native-community/template#245.Context
The incoming React Native 0.87 release will ship the Strict TypeScript API by default (moving to a user opt-out).
Typically, this change is scoped to the user's project (
@react-native/typescript-configincludesskipLibCheck: true) and not library source code.However,
react-native-safe-area-contextships a Jest integration, which is an exception that crosses this boundary:Problem:
react-native-safe-area-context/jest/mockpulls../src/*(of this library) into the scope of the user's TypeScript analysis — instead of the compiledlib/code, producing a type error against deep imports such asreact-native/Libraries/Types/CodegenTypeswhich no longer resolve (see also #744).This diff
Fix this types breakage for app consumers, independent of #744.
jest/mock.tsxtosrc/jest/mock.tsxso builder-bob compiles it like the rest of the library. Thereact-native-safe-area-context/jest/mocksubpath is preserved via shims..d.tsfiles, which are exempt from typechecking due toskipLibCheck: false.Test Plan
yarn validate:typescript, ESlint, and the Jest suite all pass.SafeAreaProvider/useSafeAreaInsets/useSafeAreaFramerender the mock metrics through context.