From 890f7c1d3a94756423dd086f5992a8f7ed068a63 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Thu, 18 Jun 2026 07:58:54 -0700 Subject: [PATCH 1/3] Delete interface.js (Flow), relocate __DEV__ global (#57275) Summary: `interface.js` was a legacy, Flow-only entry point whose sole content was a bare `declare var __DEV__: boolean;` global, registered as a Flow `[libs]` file. Relocate into `flow/globals.js`, allowing us to drop this from the package `"files"` (and `"exports"`) list. Changelog: [Internal] Differential Revision: D109018822 --- .flowconfig | 1 - packages/react-native/flow/global.js | 6 ++++++ packages/react-native/interface.js | 21 --------------------- packages/react-native/package.json | 1 - 4 files changed, 6 insertions(+), 23 deletions(-) delete mode 100644 packages/react-native/interface.js diff --git a/.flowconfig b/.flowconfig index 3a23617f8124..58ca3c06ee61 100644 --- a/.flowconfig +++ b/.flowconfig @@ -39,7 +39,6 @@ [libs] flow-typed/ -packages/react-native/interface.js packages/react-native/flow/ [options] diff --git a/packages/react-native/flow/global.js b/packages/react-native/flow/global.js index dc6de666ec02..3082f3fc48c1 100644 --- a/packages/react-native/flow/global.js +++ b/packages/react-native/flow/global.js @@ -86,3 +86,9 @@ declare var global: { // Undeclared properties are implicitly `any`. [string | symbol]: any, }; + +// Declared as a bare global so unqualified `__DEV__` references type-check as +// `boolean`. The suppression is a no-op in this checkout but avoids a duplicate +// declaration where `__DEV__` is also declared by another Flow libdef. +// $FlowFixMe[libdef-override] +declare var __DEV__: boolean; diff --git a/packages/react-native/interface.js b/packages/react-native/interface.js deleted file mode 100644 index b17169a6b153..000000000000 --- a/packages/react-native/interface.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict - * @format - */ - -'use strict'; - -// NOTE: Hmm... I don't think declaring variables within this module actually -// accomplishes anything besides documenting that these globals are expected to -// exist. So I think the correct "fix" to this lint warning is to delete this -// entire file. But in lieu of doing that... no harm for now in keeping this -// file around, even if it is only for documentation purposes. ¯\_(ツ)_/¯ - -/* eslint-disable no-unused-vars */ - -declare var __DEV__: boolean; diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 6ea146756613..01ad9377f2c3 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -80,7 +80,6 @@ "gradle/libs.versions.toml", "index.js", "index.js.flow", - "interface.js", "jest-preset.js", "Libraries", "LICENSE", From 713ed2558f747fb1bbf3eea3208da200ab37f871 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Thu, 18 Jun 2026 07:58:54 -0700 Subject: [PATCH 2/3] Narrow root wildcard entry point (#57276) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Simplify `"exports"` mapping on the `react-native` package by replacing the `"./*"` wildcard export with explicit listed subpaths (invert from blocklist to allowlist). These changes are **non-breaking** — the net accessible exports subpaths before/after are equivalent. Changelog: [Internal] Differential Revision: D109018823 --- packages/react-native/package.json | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 01ad9377f2c3..ce52edc09e9a 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -34,14 +34,14 @@ "types": "./types/index.d.ts", "default": "./index.js" }, - "./*": { + "./Libraries/*": { "react-native-strict-api": null, - "types": "./*.d.ts", - "default": "./*.js" + "types": "./Libraries/*.d.ts", + "default": "./Libraries/*.js" }, - "./*.js": { + "./Libraries/*.js": { "react-native-strict-api": null, - "default": "./*.js" + "default": "./Libraries/*.js" }, "./Libraries/*.d.ts": { "react-native-strict-api": null, @@ -56,16 +56,9 @@ "react-native-strict-api": null, "default": "./types/*.d.ts" }, - "./gradle/*": null, - "./React/*": null, - "./ReactAndroid/*": null, - "./ReactApple/*": null, - "./ReactCommon/*": null, - "./sdks/*": null, + "./jest-preset": "./jest-preset.js", + "./rn-get-polyfills": "./rn-get-polyfills.js", "./src/fb_internal/*": "./src/fb_internal/*", - "./third-party-podspecs/*": null, - "./types/*": null, - "./types_generated/*": null, "./package.json": "./package.json" }, "jest-junit": { From 567f264ae9aeee955115ec6a6b9180e704185665 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Thu, 18 Jun 2026 07:58:54 -0700 Subject: [PATCH 3/3] Hide src/ directory from TypeScript (#57277) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: **Motivation** Incremental progress towards restricting React Native's internal JavaScript source code. - `src/private/` was added relatively recently, with very little OSS code depending on it — we can action earlier. - Helps to reduce the increasingly complicated state of our root `"exports"` map. **Changes** Resolve to `null` for the `"types"` package exports condition — this hides from TypeScript suggestions/auto-import. - **Breaking**: TypeScript's language server will no longer be able to see these modules, and projects will need a `// $TSIgnore` on these imports. - The ability to access these modules is unchanged: they remain present in the bundle and accessible by Metro. Changelog: [General][Breaking] - Deep imports to `'react-native/src/private/...'` have been restricted, and are no longer visible to TypeScript. These subpaths still exist, but do not have type coverage. Differential Revision: D109018821 --- packages/react-native/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/package.json b/packages/react-native/package.json index ce52edc09e9a..ec26182439fe 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -49,7 +49,7 @@ }, "./scripts/*": "./scripts/*", "./src/*": { - "react-native-strict-api": null, + "types": null, "default": "./src/*.js" }, "./types/*.d.ts": {